Files
inkreach-agent/apps/desktop/scripts/debug-preview.cjs
T
Rick Ye a5951849c8 v0.6.0: beautifului 整合 + 会话/工作区/队列/权限/命令/附件全链路
- beautifului.dev 组件直连:Sidebar Nav、Tool Chips、Approval Card(抽屉化)、Streaming/Thinking、Code Block、Selection Actions、Prompt Bar、Search
2026-09-06 09:57:14 +08:00

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)
})