mes-vue/electron/main.cjs
shaoleiliu-netizen123 7b2b67564c Electron 打包
2026-06-25 16:09:20 +08:00

36 lines
1009 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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