提交源文件
This commit is contained in:
39
electron/main.js
Normal file
39
electron/main.js
Normal file
@@ -0,0 +1,39 @@
|
||||
import { app, BrowserWindow, ipcMain } from "electron";
|
||||
|
||||
app.whenReady().then(() => {
|
||||
const win = new BrowserWindow({
|
||||
title: "Main window",
|
||||
fullscreenable: true,
|
||||
fullscreen: true,
|
||||
simpleFullscreen: true,
|
||||
frame: false,
|
||||
webPreferences: {
|
||||
// 集成网页和 Node.js,也就是在渲染进程中,可以调用 Node.js 方法
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false,
|
||||
},
|
||||
});
|
||||
|
||||
// You can use `process.env.VITE_DEV_SERVER_URL` when the vite command is called `serve`
|
||||
if (process.env.VITE_DEV_SERVER_URL) {
|
||||
win.loadURL(process.env.VITE_DEV_SERVER_URL);
|
||||
} else {
|
||||
// Load your file
|
||||
win.loadFile("dist/index.html");
|
||||
}
|
||||
win.webContents.openDevTools();
|
||||
app.on("activate", () => {
|
||||
// 在 macOS 系统内, 如果没有已开启的应用窗口
|
||||
// 点击托盘图标时通常会重新创建一个新窗口
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
||||
});
|
||||
|
||||
ipcMain.on("quitHandler", (_, msg) => {
|
||||
console.log(msg);
|
||||
app.quit();
|
||||
});
|
||||
});
|
||||
|
||||
app.on("window-all-closed", () => {
|
||||
if (process.platform !== "darwin") app.quit();
|
||||
});
|
||||
Reference in New Issue
Block a user