36 lines
1009 B
JavaScript
36 lines
1009 B
JavaScript
const { app, BrowserWindow, Menu } = require('electron')
|
||
const path = require('path')
|
||
|
||
Menu.setApplicationMenu(null)
|
||
|
||
let mainWin = null
|
||
function createWindow() {
|
||
mainWin = new BrowserWindow({
|
||
width: 1400,
|
||
height: 900,
|
||
title: "伊特机械MES",
|
||
//关键配置,隐藏顶部File/Edit菜单栏
|
||
autoHideMenBar: true,//按ALTE可临时调出
|
||
menu: null,
|
||
webPreferences: {
|
||
nodeIntegration: true,
|
||
contextIsolation: false
|
||
}
|
||
})
|
||
|
||
// 区分 本地开发 / 打包exe 两种环境
|
||
if (app.isPackaged) {
|
||
// 打包后:读取 asar 内部资源,不能走磁盘本地路径
|
||
mainWin.loadFile(path.join(__dirname, "../dist/index.html"))
|
||
} else {
|
||
// 本地 npm run electron:dev 预览
|
||
mainWin.loadFile(path.join(__dirname, "../dist/index.html"))
|
||
// 开发时自动打开调试面板
|
||
mainWin.webContents.openDevTools()
|
||
}
|
||
}
|
||
|
||
app.whenReady().then(createWindow)
|
||
app.on('window-all-closed', () => {
|
||
if (process.platform !== 'darwin') app.quit()
|
||
}) |