bak
This commit is contained in:
@@ -187,13 +187,13 @@ if (!isFirstInstance) {
|
||||
app.quit() // 退出当前实例
|
||||
} else {
|
||||
logger.warn('未找到现有实例窗口,可能是锁未正确释放')
|
||||
logger.info('尝试强制启动新实例...')
|
||||
// 继续启动
|
||||
logger.info('强制退出当前实例,避免重复托盘')
|
||||
app.quit() // 强制退出,避免创建重复托盘
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error('激活现有实例失败:', error)
|
||||
logger.info('尝试强制启动新实例...')
|
||||
// 继续启动
|
||||
logger.info('强制退出当前实例,避免重复托盘')
|
||||
app.quit() // 强制退出,避免创建重复托盘
|
||||
}
|
||||
} else {
|
||||
logger.info('这是第一个实例,继续启动')
|
||||
@@ -233,18 +233,13 @@ if (!isFirstInstance) {
|
||||
optimizer.watchWindowShortcuts(window)
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
// 根据存储的状态决定是否创建悬浮窗口
|
||||
if (getStoreValue('showDrageWindow')) {
|
||||
createDrageWindow()
|
||||
}
|
||||
|
||||
|
||||
createWindow()
|
||||
|
||||
|
||||
createTray()
|
||||
setupIPC()
|
||||
|
||||
@@ -267,8 +262,6 @@ if (!isFirstInstance) {
|
||||
logger.info(err)
|
||||
});
|
||||
|
||||
|
||||
|
||||
app.on('activate', function () {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||
})
|
||||
@@ -294,13 +287,14 @@ if (!isFirstInstance) {
|
||||
logger.error('窗口关闭时清理缓存失败:', error);
|
||||
}
|
||||
|
||||
// 清理完成后退出应用
|
||||
// 销毁托盘并退出应用
|
||||
destroyTray()
|
||||
app.quit();
|
||||
|
||||
} else {
|
||||
// 如果是主动退出,则销毁托盘并退出应用
|
||||
destroyTray()
|
||||
|
||||
app.quit()
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -316,7 +310,8 @@ if (!isFirstInstance) {
|
||||
logger.error('应用退出时清理缓存失败:', error);
|
||||
}
|
||||
|
||||
// 清理完成后退出应用
|
||||
// 销毁托盘并退出应用
|
||||
destroyTray()
|
||||
app.quit();
|
||||
});
|
||||
|
||||
@@ -333,6 +328,7 @@ if (!isFirstInstance) {
|
||||
}
|
||||
|
||||
unregisterAllShortcuts()
|
||||
destroyTray()
|
||||
|
||||
// 清理完成后退出应用
|
||||
app.quit();
|
||||
@@ -348,6 +344,7 @@ if (!isFirstInstance) {
|
||||
} catch (error) {
|
||||
logger.error('SIGTERM 时清理缓存失败:', error);
|
||||
}
|
||||
destroyTray()
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
@@ -358,6 +355,7 @@ if (!isFirstInstance) {
|
||||
} catch (error) {
|
||||
logger.error('SIGINT 时清理缓存失败:', error);
|
||||
}
|
||||
destroyTray()
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user