- beautifului.dev 组件直连:Sidebar Nav、Tool Chips、Approval Card(抽屉化)、Streaming/Thinking、Code Block、Selection Actions、Prompt Bar、Search
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
// 预览页控制台诊断:node 调试某一分区
|
|
// npx electron scripts/debug-preview.cjs "#thinking"
|
|
const { app, BrowserWindow } = require('electron')
|
|
|
|
const hash = process.argv[2] ?? ''
|
|
const URL = `http://127.0.0.1:4173/${hash}`
|
|
|
|
// 兜底退出(渲染进程卡死时 executeJavaScript 永不返回)
|
|
const guard = setTimeout(() => {
|
|
console.log('[guard] hard exit (page busy or crashed)')
|
|
app.exit(2)
|
|
}, 12000)
|
|
|
|
app.whenReady().then(async () => {
|
|
const win = new BrowserWindow({
|
|
width: 1280,
|
|
height: 900,
|
|
show: false,
|
|
webPreferences: { offscreen: true }
|
|
})
|
|
win.webContents.on('console-message', (_e, level, message, line, source) => {
|
|
console.log(`[console:${level}]`, message, `(${source}:${line})`)
|
|
})
|
|
win.webContents.on('did-fail-load', (_e, code, desc, url) => {
|
|
console.log(`[did-fail-load] ${code} ${desc} ${url}`)
|
|
})
|
|
win.webContents.on('render-process-gone', (_e, details) => {
|
|
console.log('[crashed]', details.reason)
|
|
})
|
|
await win.loadURL(URL)
|
|
setTimeout(async () => {
|
|
try {
|
|
const text = await win.webContents.executeJavaScript('document.body.innerText.slice(0, 120)')
|
|
console.log('[body]', JSON.stringify(text))
|
|
} catch (e) {
|
|
console.log('[executeJavaScript failed]', e.message)
|
|
}
|
|
clearTimeout(guard)
|
|
app.exit(0)
|
|
}, 2500)
|
|
})
|