This commit is contained in:
2025-07-18 16:40:49 +08:00
parent 0b2974e2c9
commit 6fe479448c
4 changed files with 33 additions and 31 deletions

View File

@@ -1,7 +1,7 @@
{ {
"name": "market-manager-gui", "name": "market-manager-gui",
"version": "1.0.0", "version": "1.0.0",
"description": "苏小胭", "description": "百千万AI智能体共创平台",
"main": "./out/main/index.js", "main": "./out/main/index.js",
"author": "huashiai.com", "author": "huashiai.com",
"homepage": "https://huashiai.com", "homepage": "https://huashiai.com",

View File

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

View File

@@ -23,6 +23,13 @@ export async function clearBrowserCache() {
} }
export function createTray() { export function createTray() {
// 防止重复创建托盘
if (tray) {
logger.info('托盘已存在,跳过创建')
return
}
logger.info('开始创建托盘图标')
// 创建托盘图标 // 创建托盘图标
tray = new Tray(icon) tray = new Tray(icon)
@@ -165,7 +172,11 @@ export function createTray() {
export function destroyTray() { export function destroyTray() {
if (tray) { if (tray) {
logger.info('销毁托盘图标')
tray.destroy() tray.destroy()
tray = null tray = null
logger.info('托盘图标已销毁')
} else {
logger.info('托盘图标不存在,无需销毁')
} }
} }

View File

@@ -622,13 +622,6 @@ export function createConfigWindow() {
}) })
const h5_client_url=getStoreValue("h5_client_url")+"/electron_h5/#/config"
logger.info("======================== configWindow 11111111111:")
logger.info(h5_client_url)
// configWindow.loadURL(h5_client_url)
if (is.dev && process.env['ELECTRON_RENDERER_URL']) { if (is.dev && process.env['ELECTRON_RENDERER_URL']) {
configWindow.loadURL(process.env['ELECTRON_RENDERER_URL'] + '/#/config') configWindow.loadURL(process.env['ELECTRON_RENDERER_URL'] + '/#/config')