提交源文件
This commit is contained in:
34
dist-electron/main.js
Normal file
34
dist-electron/main.js
Normal file
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
const electron = require("electron");
|
||||
electron.app.whenReady().then(() => {
|
||||
const win = new electron.BrowserWindow({
|
||||
title: "Main window",
|
||||
fullscreenable: true,
|
||||
fullscreen: true,
|
||||
simpleFullscreen: true,
|
||||
frame: false,
|
||||
webPreferences: {
|
||||
// 集成网页和 Node.js,也就是在渲染进程中,可以调用 Node.js 方法
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false
|
||||
}
|
||||
});
|
||||
if (process.env.VITE_DEV_SERVER_URL) {
|
||||
win.loadURL(process.env.VITE_DEV_SERVER_URL);
|
||||
} else {
|
||||
win.loadFile("dist/index.html");
|
||||
}
|
||||
win.webContents.openDevTools();
|
||||
electron.app.on("activate", () => {
|
||||
if (electron.BrowserWindow.getAllWindows().length === 0)
|
||||
createWindow();
|
||||
});
|
||||
electron.ipcMain.on("quitHandler", (_, msg) => {
|
||||
console.log(msg);
|
||||
electron.app.quit();
|
||||
});
|
||||
});
|
||||
electron.app.on("window-all-closed", () => {
|
||||
if (process.platform !== "darwin")
|
||||
electron.app.quit();
|
||||
});
|
||||
Reference in New Issue
Block a user