代码拉取完成,页面将自动刷新
const { app, BrowserWindow, Menu, globalShortcut } = require("electron");
const { resolve } = require("path");
const WinState = require("electron-win-state").default;
const mainMenu = require("./mainMenu");
// const getSource = require("./controller/getSource");
/** 图片裁剪 */
require("./controller/getSource");
/** alert */
require("./controller/alert");
/** open window */
require("./controller/openWindow");
/** get FileList */
require("./controller/getFileList");
/** 菜单 */
require("./controller/buildMenu");
const createTray = require("./tray");
const WIN_STATE = new WinState({
defaultWidth: 800,
defaultHeight: 1000,
electronStoreOptions: {
name: "window-state-main"
}
});
const CREATE_WINDOW = () => {
const WIN = new BrowserWindow({
// 自定义窗口状态
...WIN_STATE.winOptions,
webPreferences: {
// 自定义预加载的js
preload: resolve(__dirname, "./preload"),
nodeIntegration: true
},
show: false,
icon: resolve(__dirname, "basketball.png")
});
WIN.setIcon('basketball.png');
WIN.loadURL("http://localhost:5173");
WIN.webContents.openDevTools();// 控制台
WIN_STATE.manage(WIN);
WIN.on("ready-to-show", () => {
WIN.show();
});
// 当你想要刷新窗口时,调用以下函数
const refreshWindow = () => WIN.webContents.reload();
globalShortcut.register("f5", () => {
refreshWindow()
});
globalShortcut.register("f6", () => {
WIN.webContents.openDevTools();// 控制台
})
// Menu.setApplicationMenu(mainMenu("就是太帅了,无法解释", (result) => {
// console.log(result);
// }));
// getSource();
createTray(app, WIN);
};
app.whenReady().then(() => {
CREATE_WINDOW();
app.on("activate", () => {
if (BrowserWindow.getAllWindows().length === 0) {
console.log("activate")
CREATE_WINDOW()
};
})
});
app.on("window-all-closed", () => {
if (process.platform === "darwin") app.quit();
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。