28 lines
1.1 KiB
JavaScript
28 lines
1.1 KiB
JavaScript
const fs = require('fs')
|
|
const p = 'C:/Users/ASUS/Documents/deepseek-harness/default-workspace/desktop-pet/src/renderer/src/menu/Menu.tsx'
|
|
let c = fs.readFileSync(p, 'utf8')
|
|
|
|
function rep(from, to) {
|
|
if (!c.includes(from)) {
|
|
console.log('MISS ::', from.slice(0, 60).replace(/\n/g, '\\n'))
|
|
return
|
|
}
|
|
c = c.replace(from, to)
|
|
}
|
|
|
|
rep(
|
|
" const [cat, setCat] = useState<Cat | null>(null)",
|
|
" const [cat, setCat] = useState<Cat | null>(null)\n const [flavor, setFlavor] = useState<'chemistry' | 'normal'>('chemistry')"
|
|
)
|
|
rep(
|
|
" void a?.getConfig().then(applyTheme)",
|
|
" void a?.getConfig().then((c2) => {\n applyTheme(c2)\n const skinId = (c2 as { currentSkin?: string }).currentSkin || 'xiaona'\n void fetch('pet://skins/' + skinId + '/skin.json')\n .then((r) => (r.ok ? r.json() : null))\n .then((m) => setFlavor(m && m.flavor === 'normal' ? 'normal' : 'chemistry'))\n .catch(() => setFlavor('chemistry'))\n })"
|
|
)
|
|
rep(
|
|
" {c.label}",
|
|
" {c.id === 'shop' && flavor === 'normal' ? '商店' : c.label}"
|
|
)
|
|
|
|
fs.writeFileSync(p, c, 'utf8')
|
|
console.log('menu flavor patched')
|