feat: 初始化项目

This commit is contained in:
DEV_DSW
2025-09-22 17:05:21 +08:00
parent 1347e31f83
commit 329fc3eb0e
21 changed files with 9462 additions and 1 deletions

46
electron/main.js Normal file
View File

@@ -0,0 +1,46 @@
const { app, ipcMain, BrowserWindow } = require("electron");
const { join } = require("path");
const createTray = require("../controller/tray");
// 映射页面
const env = app.isPackaged ? "production" : "development";
const createWindow = () => {
const win = new BrowserWindow({
width: 800,
height: 600,
frame: false, // 不要自带的窗口
webPreferences: {
preload: join(__dirname, "./preload/index.js"),
},
});
if (env === "development") {
win.loadURL("http://localhost:5173");
// 打开开发工具 { mode: "detach" }
// win.webContents.openDevTools();
} else {
win.loadFile("../dist/index.html");
}
// 系统托盘
createTray(app, win);
};
ipcMain.handle("sent-event", (event, params) => {
console.log(params);
return "1111";
});
app.whenReady().then(() => {
createWindow();
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
app.on("window-all-closed", () => {
if (process.platform !== "darwin") app.quit();
});