优化重启逻辑
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { app, shell, BrowserWindow, ipcMain, Menu, session, screen, dialog } from 'electron'
|
||||
import { electronApp, optimizer } from '@electron-toolkit/utils'
|
||||
import Store from 'electron-store'
|
||||
import { createWindow, createDrageWindow, unregisterAllShortcuts } from './window.js'
|
||||
import { createWindow, createDrageWindow, unregisterAllShortcuts, getMainWindow } from './window.js'
|
||||
import { setupIPC } from './ipc.js'
|
||||
import { createTray, destroyTray,clearBrowserCache } from './tray.js'
|
||||
import XEUtils from 'xe-utils'
|
||||
@@ -13,6 +13,7 @@ import { clearAllSessionData } from './utils/cacheUtils.js'
|
||||
import SingleInstanceManager from './utils/singleInstance.js'
|
||||
import { setStoreValue, getStoreValue ,deleteStore} from './store.js'
|
||||
import AutoLaunch from 'auto-launch'
|
||||
import axios from 'axios'
|
||||
|
||||
import WebSocketClient from './utils/WebSocketClient';
|
||||
|
||||
@@ -273,6 +274,12 @@ if (!isFirstInstance) {
|
||||
app.on('window-all-closed', async (event) => {
|
||||
if (process.platform !== 'darwin') {
|
||||
event.preventDefault();
|
||||
// 如果是重启过程,不执行任何清理操作
|
||||
if (app.isRestarting) {
|
||||
logger.info('检测到重启过程,跳过窗口关闭处理')
|
||||
return;
|
||||
}
|
||||
|
||||
if (!app.isQuiting) {
|
||||
|
||||
// 如果不是主动退出,则隐藏所有窗口
|
||||
@@ -300,6 +307,12 @@ if (!isFirstInstance) {
|
||||
})
|
||||
|
||||
app.on('before-quit', async (event) => {
|
||||
// 如果是重启过程,不执行任何清理操作
|
||||
if (app.isRestarting) {
|
||||
logger.info('检测到重启过程,跳过before-quit处理')
|
||||
return;
|
||||
}
|
||||
|
||||
// 在应用程序即将退出时执行操作,例如保存数据
|
||||
event.preventDefault();
|
||||
|
||||
@@ -317,6 +330,11 @@ if (!isFirstInstance) {
|
||||
|
||||
// 在应用退出时注销所有快捷键
|
||||
app.on('will-quit', async (event) => {
|
||||
// 如果是重启过程,不执行任何清理操作
|
||||
if (app.isRestarting) {
|
||||
logger.info('检测到重启过程,跳过will-quit处理')
|
||||
return;
|
||||
}
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user