正在显示
2 个修改的文件
包含
11 行增加
和
12 行删除
| ... | @@ -3,10 +3,16 @@ | ... | @@ -3,10 +3,16 @@ |
| 3 | import { app } from 'electron' | 3 | import { app } from 'electron' |
| 4 | import initWindow from './services/windowManager' | 4 | import initWindow from './services/windowManager' |
| 5 | import DisableButton from './config/DisableButton' | 5 | import DisableButton from './config/DisableButton' |
| 6 | +import electronDevtoolsInstaller, { VUEJS_DEVTOOLS } from 'electron-devtools-installer' | ||
| 6 | 7 | ||
| 7 | -function onAppReady () { | 8 | +function onAppReady() { |
| 8 | new initWindow().initWindow() | 9 | new initWindow().initWindow() |
| 9 | DisableButton.Disablef12() | 10 | DisableButton.Disablef12() |
| 11 | + if (process.env.NODE_ENV === 'development') { | ||
| 12 | + electronDevtoolsInstaller(VUEJS_DEVTOOLS) | ||
| 13 | + .then((name) => console.log(`已安装: ${name}`)) | ||
| 14 | + .catch(err => console.log('无法安装 `vue-devtools`: \n 可能发生得错误:网络连接问题 \n', err)) | ||
| 15 | + } | ||
| 10 | } | 16 | } |
| 11 | 17 | ||
| 12 | app.isReady() ? onAppReady() : app.on('ready', onAppReady) | 18 | app.isReady() ? onAppReady() : app.on('ready', onAppReady) | ... | ... |
| ... | @@ -60,21 +60,14 @@ class MainInit { | ... | @@ -60,21 +60,14 @@ class MainInit { |
| 60 | new Update(this.mainWindow) | 60 | new Update(this.mainWindow) |
| 61 | // 启用协议,这里暂时只用于自定义头部的时候使用 | 61 | // 启用协议,这里暂时只用于自定义头部的时候使用 |
| 62 | setIpc.Mainfunc(this.mainWindow, config.IsUseSysTitle) | 62 | setIpc.Mainfunc(this.mainWindow, config.IsUseSysTitle) |
| 63 | - // 安装devtools | 63 | + // dom-ready之后显示界面 |
| 64 | - if (process.env.NODE_ENV === 'development') { | ||
| 65 | - this.mainWindow.webContents.once('dom-ready', () => { | ||
| 66 | - this.mainWindow.show() | ||
| 67 | - electronDevtoolsInstaller(VUEJS_DEVTOOLS) | ||
| 68 | - .then((name) => console.log(`已安装: ${name}`)) | ||
| 69 | - .catch(err => console.log('无法安装 `vue-devtools`: \n 可能发生得错误:网络连接问题 \n', err)) | ||
| 70 | - if (config.UseStartupChart) this.loadWindow.destroy() | ||
| 71 | - this.mainWindow.webContents.openDevTools({ mode: 'undocked', activate: true }) | ||
| 72 | - }) | ||
| 73 | - } else { | ||
| 74 | this.mainWindow.webContents.once('dom-ready', () => { | 64 | this.mainWindow.webContents.once('dom-ready', () => { |
| 75 | this.mainWindow.show() | 65 | this.mainWindow.show() |
| 76 | if (config.UseStartupChart) this.loadWindow.destroy() | 66 | if (config.UseStartupChart) this.loadWindow.destroy() |
| 77 | }) | 67 | }) |
| 68 | + // 开发模式下自动开启devtools | ||
| 69 | + if (process.env.NODE_ENV === 'development') { | ||
| 70 | + this.mainWindow.webContents.openDevTools({ mode: 'undocked', activate: true }) | ||
| 78 | } | 71 | } |
| 79 | // 当确定渲染进程卡死时 | 72 | // 当确定渲染进程卡死时 |
| 80 | this.mainWindow.webContents.on('crashed', () => { | 73 | this.mainWindow.webContents.on('crashed', () => { | ... | ... |
-
请 注册 或 登录 后发表评论