34 lines
1.0 KiB
JavaScript
34 lines
1.0 KiB
JavaScript
const fs = require('fs')
|
|
const p = 'C:/Users/ASUS/Documents/deepseek-harness/default-workspace/desktop-pet/src/renderer/src/App.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)
|
|
}
|
|
|
|
// 组件级 ref
|
|
rep(
|
|
" const cfgRef = useRef<PetConfig>(DEFAULT_CONFIG)",
|
|
" const cfgRef = useRef<PetConfig>(DEFAULT_CONFIG)\n const loadedSkinRef = useRef('')"
|
|
)
|
|
// 移除 effect 内局部声明
|
|
rep(
|
|
" const loadedSkinRef = { value: '' }\n\n async function boot(): Promise<void> {",
|
|
" async function boot(): Promise<void> {"
|
|
)
|
|
rep(
|
|
" loadedSkinRef.value = cfgRef.current.currentSkin || 'xiaona'",
|
|
" loadedSkinRef.current = cfgRef.current.currentSkin || 'xiaona'"
|
|
)
|
|
rep(
|
|
" if ((cfg.currentSkin || 'xiaona') !== loadedSkinRef.value) {",
|
|
" if ((cfg.currentSkin || 'xiaona') !== loadedSkinRef.current) {"
|
|
)
|
|
|
|
fs.writeFileSync(p, c, 'utf8')
|
|
console.log('app skin ref fixed')
|