Files
ClassContent/历届学生/front-end-team/项目练习/上课项目/聊天室/fontend/main.js
2024-09-27 02:06:13 +08:00

57 lines
1.3 KiB
JavaScript

const { app, BrowserWindow, ipcMain, Menu } = require('electron')
const path = require('path')
var index = 0;
var mainWindow = null;
var config = [
{
path: 'page/login.html',
windowConfig: {
title: '乐聊 - 登录',
width: 316,
height: 507,
resizable: false,
webPreferences: {
nodeIntegration: true,
nodeIntegrationInWorker: true,
contextIsolation: false
}
}
},
{
path: 'page/index.html',
windowConfig: {
title: '',
icon: null,
width: 800,
height: 600,
autoHideMenuBar: true,
webPreferences: {
nodeIntegration: true,
nodeIntegrationInWorker: true,
contextIsolation: false
}
}
}
];
const createWindow = () => {
Menu.setApplicationMenu(null);
mainWindow = new BrowserWindow(config[index].windowConfig)
mainWindow.webContents.openDevTools();
mainWindow.loadFile(config[index].path)
}
ipcMain.on("GoToIndex",(action, res) => {
mainWindow.close();
index = 1;
createWindow()
})
app.whenReady().then(() => {
createWindow()
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit()
})