Skip to content

Commit

Permalink
optimize: 捕获DS的各种未知异常,并将异常信息记录到日志文件中。
Browse files Browse the repository at this point in the history
  • Loading branch information
wangliang181230 committed Jan 27, 2025
1 parent fe060eb commit 89b096d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
1 change: 0 additions & 1 deletion packages/gui/src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ function createWindow (startHideWindow, autoQuitIfError = true) {
enableRemoteModule: true,
contextIsolation: false,
nativeWindowOpen: true, // ADD THIS
// preload: path.join(__dirname, 'preload.js'),
// Use pluginOptions.nodeIntegration, leave this alone
// See nklayman.github.io/vue-cli-plugin-electron-builder/guide/security.html#node-integration for more info
nodeIntegration: true, // process.env.ELECTRON_NODE_INTEGRATION
Expand Down
16 changes: 8 additions & 8 deletions packages/gui/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import 'ant-design-vue/dist/antd.css'
import './view/style/index.scss'
import './view/style/theme/dark.scss' // 暗色主题

try {
window.onerror = (message, source, lineno, colno, error) => {
ipcRenderer.send(`[ERROR] JavaScript脚本异常:Error in ${source} at line ${lineno}: ${message}`, error)
}
} catch (e) {
console.error('监听 window.onerror 出现异常:', e)
}

try {
Vue.config.productionTip = false
Vue.use(antd)
Expand Down Expand Up @@ -52,11 +60,3 @@ try {
console.error('页面加载出现未知异常:', e)
ipcRenderer.send('[ERROR] 页面加载出现未知异常:', e)
}

try {
window.onerror = (message, source, lineno, colno, error) => {
ipcRenderer.send(`[ERROR] JavaScript脚本异常:Error in ${source} at line ${lineno}: ${message}`, error)
}
} catch (e) {
console.error('监听 window.onerror 出现异常:', e)
}
9 changes: 0 additions & 9 deletions packages/gui/src/preload.js

This file was deleted.

0 comments on commit 89b096d

Please sign in to comment.