const fs = require('fs') const base = 'C:/Users/ASUS/Documents/deepseek-harness/default-workspace/desktop-pet/src/' function patch(file, pairs) { const p = base + file let c = fs.readFileSync(p, 'utf8') for (const [from, to] of pairs) { if (!c.includes(from)) { console.log('MISS in', file, '::', from.slice(0, 70).replace(/\n/g, '\\n')) continue } c = c.replace(from, to) } fs.writeFileSync(p, c, 'utf8') } // Panel:菜单导航到「详细」时打开独立窗口,不再调用不存在的 setDetail patch('renderer/src/panel/Panel.tsx', [ [ ` if (nav.tab === 'detail') { setTab('panel') setDetail(true) return }`, ` if (nav.tab === 'detail') { setTab('panel') api()?.openDetail() return }` ] ]) // api.ts:去掉重复/过期的 createProfile、switchProfile 声明 patch('renderer/src/api.ts', [ [ ` createProfile: (name: string, skinId: string) => Promise> renameProfile: (id: string, name: string) => Promise> renameSkin: (id: string, name: string) => Promise> delProfile: (id: string) => Promise> onLook: (cb: (p: { x: number; y: number }) => void) => () => void onSkins: (cb: (list: Array<{ id: string; name: string; active: boolean }>) => void) => () => void createProfile: (name: string) => Promise> switchProfile: (id: string) => Promise>`, ` createProfile: (name: string, skinId: string) => Promise> renameProfile: (id: string, name: string) => Promise> renameSkin: (id: string, name: string) => Promise> delProfile: (id: string) => Promise> switchProfile: (id: string) => Promise> onLook: (cb: (p: { x: number; y: number }) => void) => () => void onSkins: (cb: (list: Array<{ id: string; name: string; active: boolean }>) => void) => () => void` ] ]) // Detail:PetState -> PetSave patch('renderer/src/detail/Detail.tsx', [ [ "import type { PetState } from '../../../shared/petState'", "import type { PetSave } from '../../../shared/petState'" ], [ " const [state, setState] = useState(null)", " const [state, setState] = useState(null)" ], [ ` {(state.log || []).map((line, i) => (`, ` {(state.log || []).map((line: string, i: number) => (` ] ]) // Storage:类型导入路径修正 patch('renderer/src/storage/Storage.tsx', [ [ "import type { FileMeta, PhotoMeta } from '../../shared/media'", "import type { FileMeta, PhotoMeta } from '../../../shared/media'" ] ]) console.log('type errors patched')