const fs = require('fs') const p = 'C:/Users/ASUS/Documents/deepseek-harness/default-workspace/desktop-pet/src/renderer/src/panel/Panel.tsx' let c = fs.readFileSync(p, 'utf8') function rep(from, to) { if (!c.includes(from)) { console.log('MISS ::', from.slice(0, 80).replace(/\n/g, '\\n')) return } c = c.replace(from, to) } rep( "import type { JobDef } from '../../../shared/petState'", "import type { JobDef } from '../../../shared/petState'\nimport type { FileMeta, PhotoMeta } from '../../../shared/media'" ) rep( " { id: 'shop', label: '试剂店' },", " { id: 'shop', label: '试剂店' },\n { id: 'photos', label: '图库' }," ) rep( " const [llm, setLlm] = useState(null)", " const [llm, setLlm] = useState(null)\n const [photos, setPhotos] = useState([])\n const [files, setFiles] = useState([])" ) rep( " void a?.getLlm().then(setLlm)\n const timer = setInterval(() => setNow(Date.now()), 500)", " void a?.getLlm().then(setLlm)\n void a?.getPhotos().then(setPhotos)\n void a?.getFiles().then(setFiles)\n const offPhotos = a?.onPhotos(setPhotos)\n const offFiles = a?.onFiles(setFiles)\n const timer = setInterval(() => setNow(Date.now()), 500)" ) rep( " offState?.()\n offCfg?.()\n clearInterval(timer)", " offState?.()\n offCfg?.()\n offPhotos?.()\n offFiles?.()\n clearInterval(timer)" ) // 图库 tab:放在设置之前 rep( ` {tab === 'settings' && cfg && (`, ` {tab === 'photos' && ( <>
图库
{photos.length === 0 && (
还没有照片,点上面的「拍照」存一张吧
)}
{photos.map((p) => (
))}
文件袋 · 把文件拖到小钠身上
{files.length === 0 &&
还没有文件,拖一个给她试试
}
{files.map((f) => (
{f.name}
{f.original}
))}
)} {tab === 'settings' && cfg && (` ) fs.writeFileSync(p, c, 'utf8') console.log('panel photos patched')