1 Star 0 Fork 0

地沟油吃多了/vue3-electron-demo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.js 2.05 KB
一键复制 编辑 原始数据 按行查看 历史
地沟油吃多了 提交于 2024-05-09 22:33 . electron-builder
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();
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/rankl/vue3-electron-demo.git
git@gitee.com:rankl/vue3-electron-demo.git
rankl
vue3-electron-demo
vue3-electron-demo
master

搜索帮助