Files
SodiumPet/tools/patch-p33-b.cjs

78 lines
3.2 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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<Array<{ id: string; name: string; active: boolean; level: string }>>
renameProfile: (id: string, name: string) => Promise<Array<{ id: string; name: string; active: boolean; level: string }>>
renameSkin: (id: string, name: string) => Promise<Array<{ id: string; name: string; active: boolean }>>
delProfile: (id: string) => Promise<Array<{ id: string; name: string; active: boolean; level: string }>>
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<Array<{ id: string; active: boolean }>>
switchProfile: (id: string) => Promise<Array<{ id: string; active: boolean }>>`,
` createProfile: (name: string, skinId: string) => Promise<Array<{ id: string; name: string; active: boolean; level: string }>>
renameProfile: (id: string, name: string) => Promise<Array<{ id: string; name: string; active: boolean; level: string }>>
renameSkin: (id: string, name: string) => Promise<Array<{ id: string; name: string; active: boolean }>>
delProfile: (id: string) => Promise<Array<{ id: string; name: string; active: boolean; level: string }>>
switchProfile: (id: string) => Promise<Array<{ id: string; name: string; active: boolean; level: string }>>
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<PetState | null>(null)",
" const [state, setState] = useState<PetSave | null>(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')