45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
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')
|
|
}
|
|
|
|
// 文件袋显示名去掉时间戳前缀
|
|
const displayName = (name) => name.replace(/^\d+-/, '')
|
|
patch('renderer/src/panel/Panel.tsx', [
|
|
[
|
|
` {fileIcon(f.name)} {f.name}`,
|
|
` {fileIcon(f.name)} \${displayName(f.name)}`
|
|
],
|
|
[
|
|
`function fileIcon(name: string): string {
|
|
for (const [re, icon] of FILE_ICONS) if (re.test(name)) return icon
|
|
return '📁'
|
|
}`,
|
|
`function fileIcon(name: string): string {
|
|
for (const [re, icon] of FILE_ICONS) if (re.test(name)) return icon
|
|
return '📁'
|
|
}
|
|
|
|
function displayName(name: string): string {
|
|
return name.replace(/^\\d+-/, '')
|
|
}`
|
|
]
|
|
])
|
|
patch('renderer/src/storage/Storage.tsx', [
|
|
[
|
|
` {fileIcon(f.name)} {f.name}`,
|
|
` {fileIcon(f.name)} {f.name.replace(/^\\d+-/, '')}`
|
|
]
|
|
])
|
|
console.log('display name patched')
|