移除调试代码
This commit is contained in:
parent
bfc8dc2e60
commit
cc8a8e142e
57
src/main.ts
57
src/main.ts
@ -141,6 +141,17 @@ const createWindow = () => {
|
||||
callback(true);
|
||||
});
|
||||
|
||||
// 最小化到系统托盘
|
||||
win.on('minimize', () => {
|
||||
win.hide();
|
||||
});
|
||||
|
||||
// 监听窗口关闭(用户点击右上角X)
|
||||
win.on('close', (event) => {
|
||||
event.preventDefault();
|
||||
win.hide();
|
||||
});
|
||||
|
||||
// production a bad jabe
|
||||
const handleDevTools = () => {
|
||||
if (win.webContents.isDevToolsOpened()) {
|
||||
@ -158,27 +169,13 @@ const createWindow = () => {
|
||||
win.loadFile(path.join(__dirname, `../renderer/${MAIN_WINDOW_VITE_NAME}/login.html`));
|
||||
}
|
||||
|
||||
// 最小化到系统托盘
|
||||
win.on('minimize', () => {
|
||||
win.hide(); // 隐藏窗口
|
||||
});
|
||||
|
||||
// 监听窗口关闭(用户点击右上角X)
|
||||
win.on('close', (event) => {
|
||||
event.preventDefault();
|
||||
win.hide();
|
||||
});
|
||||
|
||||
// 创建托盘图标
|
||||
const iconPath = path.join(process.resourcesPath, 'assets', 'tray.png');
|
||||
console.log(iconPath);
|
||||
const tray = new Tray(iconPath);
|
||||
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{ label: '显示窗口', click: () => win.show() },
|
||||
{ label: '退出程序', click: () => app.exit() }
|
||||
]);
|
||||
|
||||
const iconPath = path.join(process.resourcesPath, 'assets', 'tray.png');
|
||||
const tray = new Tray(iconPath);
|
||||
tray.setToolTip('中国电信-工作台');
|
||||
tray.setContextMenu(contextMenu);
|
||||
|
||||
@ -188,11 +185,6 @@ const createWindow = () => {
|
||||
});
|
||||
};
|
||||
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
app.on('ready', createWindow);
|
||||
|
||||
// 在非 macOS 平台上,关闭所有窗口时退出应用
|
||||
// Quit when all windows are closed, except on macOS. There, it's common
|
||||
// for applications and their menu bar to stay active until the user quits
|
||||
@ -203,11 +195,18 @@ app.on('window-all-closed', () => {
|
||||
}
|
||||
});
|
||||
|
||||
// 在 macOS 平台上,点击 dock 图标时重新创建窗口
|
||||
app.on('activate', () => {
|
||||
// On OS X it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow();
|
||||
}
|
||||
});
|
||||
// This method will be called when Electron has finished
|
||||
// initialization and is ready to create browser windows.
|
||||
// Some APIs can only be used after this event occurs.
|
||||
app.whenReady().then(() => {
|
||||
createWindow();
|
||||
|
||||
// 在 macOS 平台上,点击 dock 图标时重新创建窗口
|
||||
app.on('activate', () => {
|
||||
// On OS X it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
if (BrowserWindow.getAllWindows().length === 0) {
|
||||
createWindow();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user