Files
electron-vue/main.js
T
2026-05-21 00:12:44 +08:00

34 lines
737 B
JavaScript

const { app, BrowserWindow } = require('electron');
const path = require('path');
let win;
function createWindow() {
win = new BrowserWindow({
width: 500,
height: 400,
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
preload: path.join(__dirname, 'preload.js')
}
});
win.loadFile('index.html');
// 打开开发者工具方便调试
// win.webContents.openDevTools();
}
app.whenReady().then(createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});