You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.7 KiB
57 lines
1.7 KiB
const { app, BrowserWindow , screen } = require('electron')
|
|
const { join } = require('path')
|
|
|
|
// 屏蔽安全警告
|
|
// ectron Security Warning (Insecure Content-Security-Policy)
|
|
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true'
|
|
|
|
// 创建浏览器窗口时,调用这个函数。
|
|
const createWindow = () => {
|
|
const win = new BrowserWindow({
|
|
width: 800,
|
|
height: 600,
|
|
title:'沈阳华翔',//标题
|
|
icon: join(__dirname, '../public/app.ico'),//图标
|
|
// frame:false,//Frame是否可见
|
|
autoHideMenuBar:true,//隐藏菜单栏
|
|
})
|
|
// 获取主屏幕的分辨率
|
|
const screenRect = screen.getPrimaryDisplay().bounds;
|
|
// 设置窗口大小和位置
|
|
|
|
win.setBounds({
|
|
x: 0,
|
|
y: 0,
|
|
width: screenRect.width,
|
|
height: screenRect.height,
|
|
});
|
|
console.log(process.env.npm_lifecycle_event);
|
|
// if (process.env.npm_lifecycle_event === "start") {
|
|
// win.loadURL("http://127.0.0.1:3212");
|
|
// win.webContents.openDevTools();
|
|
// //快捷命令shift+ctrl+i
|
|
// } else {
|
|
// win.loadFile("dist/index.html");
|
|
// }
|
|
// development模式
|
|
if(process.env.VITE_DEV_SERVER_URL) {
|
|
win.loadURL(process.env.VITE_DEV_SERVER_URL)
|
|
// 开启调试台
|
|
win.webContents.openDevTools()
|
|
}else {
|
|
win.loadFile(join(__dirname, '../dist/index.html'))
|
|
}
|
|
}
|
|
|
|
|
|
// Electron 会在初始化后并准备
|
|
app.whenReady().then(() => {
|
|
createWindow()
|
|
app.on('activate', () => {
|
|
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
|
})
|
|
})
|
|
|
|
app.on('window-all-closed', () => {
|
|
if (process.platform !== 'darwin') app.quit()
|
|
})
|
|
|