83 lines
2.2 KiB
JavaScript
83 lines
2.2 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')
|
|
}
|
|
|
|
// ---- main:详情窗口
|
|
patch('main/index.ts', [
|
|
[
|
|
"let storageWindow: BrowserWindow | null = null",
|
|
"let storageWindow: BrowserWindow | null = null\nlet detailWindow: BrowserWindow | null = null"
|
|
],
|
|
[
|
|
`function createStorageWindow(): void {`,
|
|
`function createDetailWindow(): void {
|
|
if (detailWindow && !detailWindow.isDestroyed()) {
|
|
detailWindow.show()
|
|
detailWindow.focus()
|
|
return
|
|
}
|
|
detailWindow = new BrowserWindow({
|
|
width: 720,
|
|
height: 520,
|
|
minWidth: 520,
|
|
minHeight: 380,
|
|
show: false,
|
|
frame: false,
|
|
resizable: true,
|
|
backgroundColor: '#0d1017',
|
|
webPreferences: {
|
|
preload: path.join(__dirname, '../preload/index.js'),
|
|
contextIsolation: true,
|
|
nodeIntegration: false,
|
|
sandbox: false
|
|
}
|
|
})
|
|
detailWindow.loadFile(path.join(__dirname, '../renderer/index.html'), {
|
|
query: { view: 'detail' }
|
|
})
|
|
detailWindow.once('ready-to-show', () => detailWindow?.show())
|
|
detailWindow.on('closed', () => {
|
|
detailWindow = null
|
|
})
|
|
}
|
|
|
|
function createStorageWindow(): void {`
|
|
],
|
|
[
|
|
` ipcMain.on('pet:storage:open', () => createStorageWindow())`,
|
|
` ipcMain.on('pet:storage:open', () => createStorageWindow())
|
|
ipcMain.on('pet:detail:open', () => createDetailWindow())`
|
|
]
|
|
])
|
|
|
|
// ---- preload / api
|
|
patch('preload/index.ts', [
|
|
[
|
|
" openStorage: () => void",
|
|
" openStorage: () => void\n openDetail: () => void"
|
|
],
|
|
[
|
|
" openStorage: () => ipcRenderer.send('pet:storage:open'),",
|
|
" openStorage: () => ipcRenderer.send('pet:storage:open'),\n openDetail: () => ipcRenderer.send('pet:detail:open'),"
|
|
]
|
|
])
|
|
patch('renderer/src/api.ts', [
|
|
[
|
|
" openStorage: () => void",
|
|
" openStorage: () => void\n openDetail: () => void"
|
|
]
|
|
])
|
|
|
|
console.log('detail window patched')
|