|
|
@@ -38,21 +38,24 @@ const showLoading = () => {
|
|
|
// 创建主程序 窗口
|
|
|
const createWindow = () => {
|
|
|
win = new BrowserWindow({
|
|
|
- maxWidth: 1920,
|
|
|
- maxHeight: 1080,
|
|
|
minWidth: 1620,
|
|
|
minHeight: 900,
|
|
|
webPreferences: {
|
|
|
- contextIsolation: false,
|
|
|
+ contextIsolation: true,
|
|
|
nodeIntegration: true,
|
|
|
- webSecurity: false // 去掉跨越
|
|
|
+ webSecurity: false,
|
|
|
+ preload: path.join(__dirname, 'preload.js')
|
|
|
},
|
|
|
show: false
|
|
|
})// 创建一个窗口
|
|
|
- // 在窗口内要展示的内容index.html 就是打包生成的index.html
|
|
|
- win.loadFile('dist/index.html')
|
|
|
- // 开启调试工具
|
|
|
- // win.webContents.openDevTools();
|
|
|
+
|
|
|
+ // 不同环境加载不同文件
|
|
|
+ if (app.isPackaged) {
|
|
|
+ win.loadFile('dist/index.html')
|
|
|
+ } else {
|
|
|
+ win.loadURL('http://localhost:6547/')
|
|
|
+ }
|
|
|
+
|
|
|
// 事件监听
|
|
|
win.on('close', () => {
|
|
|
// 回收BrowserWindow对象
|
|
|
@@ -69,6 +72,11 @@ app.on('ready', async () => {
|
|
|
loadingWin.close()
|
|
|
win.show()
|
|
|
})
|
|
|
+
|
|
|
+ // 在BrowserWindow创建完成后,注册全局快捷键
|
|
|
+ globalShortcut.register('Control+F12', () => {
|
|
|
+ win.webContents.toggleDevTools()
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
app.on('window-all-closed', () => {
|