80 lines
2.4 KiB
JavaScript
80 lines
2.4 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')
|
|
}
|
|
|
|
// ---- A. 气泡 440 宽、对话条 420 宽并下移
|
|
patch('main/index.ts', [
|
|
[' width: 320,\n height: 96,', ' width: 440,\n height: 96,'],
|
|
[' x: Math.round(b.x + (b.width - 320) / 2),\n width: 320,', ' x: Math.round(b.x + (b.width - 440) / 2),\n width: 440,'],
|
|
[' x: Math.round(b.x + (b.width - 320) / 2),\n width: 320,', ' x: Math.round(b.x + (b.width - 440) / 2),\n width: 440,'],
|
|
[' width: 330,\n height: 54,', ' width: 420,\n height: 54,'],
|
|
[' x: Math.round(b.x + b.width / 2 - 165),\n y: Math.max(0, b.y - 140),\n width: 330,', ' x: Math.round(b.x + b.width / 2 - 210),\n y: Math.max(0, b.y - 118),\n width: 420,']
|
|
])
|
|
|
|
// ---- B. Storage 主题同步
|
|
patch('renderer/src/storage/Storage.tsx', [
|
|
[
|
|
` useEffect(() => {
|
|
const a = api()
|
|
void a?.getPhotos().then(setPhotos)`,
|
|
` useEffect(() => {
|
|
const a = api()
|
|
const applyTheme = (c: { theme: string; accent: string }): void => {
|
|
document.documentElement.dataset.theme = c.theme
|
|
document.documentElement.style.setProperty('--accent', c.accent)
|
|
}
|
|
void a?.getConfig().then(applyTheme)
|
|
const offCfg = a?.onConfig(applyTheme)
|
|
void a?.getPhotos().then(setPhotos)`
|
|
],
|
|
[
|
|
` return () => {
|
|
offP?.()
|
|
offF?.()
|
|
}
|
|
}, [])`,
|
|
` return () => {
|
|
offP?.()
|
|
offF?.()
|
|
offCfg?.()
|
|
}
|
|
}, [])`
|
|
]
|
|
])
|
|
|
|
// ---- 日间滑杆底色
|
|
patch('renderer/src/panel/panel.css', [
|
|
[
|
|
`[data-theme='day'] .panel input[type='range'] { accent-color: var(--accent, #b8860b); }`,
|
|
`[data-theme='day'] .panel input[type='range'] {
|
|
accent-color: var(--accent, #b8860b);
|
|
-webkit-appearance: none;
|
|
height: 6px;
|
|
border-radius: 3px;
|
|
background: #c9d4e4;
|
|
}
|
|
[data-theme='day'] .panel input[type='range']::-webkit-slider-thumb {
|
|
-webkit-appearance: none;
|
|
width: 15px;
|
|
height: 15px;
|
|
border-radius: 50%;
|
|
background: var(--accent, #b8860b);
|
|
border: none;
|
|
cursor: pointer;
|
|
}`
|
|
]
|
|
])
|
|
|
|
console.log('windows/theme patched')
|