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') } // ---- A. 视线跟随:hover 也更新 + 关闭时复位 patch('renderer/src/App.tsx', [ [ ` function onPointerMove(e: React.PointerEvent): void { const d = dragRef.current if (!d.active) return if (e.buttons === 0) { endDrag() return }`, ` function onPointerMove(e: React.PointerEvent): void { // 视线跟随:只要鼠标在窗口内移动就更新(不要求按住) if (cfg.eyeFollow) { adapterRef.current?.lookAt?.(e.clientX + cfg.cropLeft, e.clientY + cfg.cropTop) } const d = dragRef.current if (!d.active) return if (e.buttons === 0) { endDrag() return }` ], [ ` useEffect(() => { cfgRef.current = cfg document.documentElement.dataset.theme = cfg.theme const w = DESIGN_W * cfg.scale const h = DESIGN_H * cfg.scale adapterRef.current?.resize(w, h) }, [cfg])`, ` useEffect(() => { cfgRef.current = cfg document.documentElement.dataset.theme = cfg.theme const w = DESIGN_W * cfg.scale const h = DESIGN_H * cfg.scale adapterRef.current?.resize(w, h) if (!cfg.eyeFollow) adapterRef.current?.lookAt?.(-1, -1) }, [cfg])` ] ]) // lookAt 传 -1 表示复位(看正前方) patch('renderer/src/pet/adapters/live2d.ts', [ [ ` lookAt(x: number, y: number): void { try { this.model?.focus(x, y) } catch { /* 某些模型没有视线参数,忽略 */ } }`, ` lookAt(x: number, y: number): void { try { if (x < 0 || y < 0) { // 复位:看向画布中央偏下,即正前方 this.model?.focus(this.baseSize.w / 2, this.baseSize.h * 1.5) return } this.model?.focus(x, y) } catch { /* 某些模型没有视线参数,忽略 */ } }` ] ]) // ---- B. 随机事件开关 + C. 屏幕识别指令扩展 patch('shared/petState.ts', [ [ ` /** 作息:自动睡觉/起床 HH:MM */ sleepAt: string wakeAt: string`, ` /** 作息:自动睡觉/起床 HH:MM */ sleepAt: string wakeAt: string /** 随机事件(遇水等) */ eventsEnabled: boolean /** 当前皮肤 id */ currentSkin: string /** 当前角色存档 id */ profile: string` ], [ ` sleepAt: '23:30', wakeAt: '07:30',`, ` sleepAt: '23:30', wakeAt: '07:30', eventsEnabled: true, currentSkin: 'xiaona', profile: '',` ] ]) patch('main/index.ts', [ [ ` // 遇水危机:醒着、没在打工时随机出现 if (!snap.sleeping && !snap.job && Math.random() < 0.35) { startWaterEvent() } // 正电荷过载:电子过低时提醒(10 分钟冷却) if (snap.stats.electron < 18 && Date.now() > lastChargeBark) {`, ` // 遇水危机:醒着、没在打工时随机出现(可整体关闭) if (cfgNow.eventsEnabled && !snap.sleeping && !snap.job && Math.random() < 0.35) { startWaterEvent() } // 正电荷过载:电子过低时提醒(10 分钟冷却) if (cfgNow.eventsEnabled && snap.stats.electron < 18 && Date.now() > lastChargeBark) {` ], [ ` const screenM = t.match(/^(?:看看屏幕|看下屏幕|屏幕|桌面)/i)`, ` const screenM = t.match( /^(?:看看屏幕|看下屏幕|看桌面|看看桌面|识别屏幕|识别屏幕文本|屏幕文字|屏幕文本|读屏|屏幕|桌面)/ )` ] ]) // ---- 设置页:事件开关 patch('renderer/src/panel/Panel.tsx', [ [ `
饿了自动买饭团`, `
随机事件(遇水等) void patchConfig({ eventsEnabled: e.target.checked })} />
饿了自动买饭团` ] ]) console.log('A/B/C patched')