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",
"version": "1.0.0",
"description": "苏小胭",
"description": "百千万AI智能体共创平台",
"main": "./out/main/index.js",
"author": "huashiai.com",
"homepage": "https://huashiai.com",

View File

@@ -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);
});

View File

@@ -23,6 +23,13 @@ export async function clearBrowserCache() {
}
export function createTray() {
// 防止重复创建托盘
if (tray) {
logger.info('托盘已存在,跳过创建')
return
}
logger.info('开始创建托盘图标')
// 创建托盘图标
tray = new Tray(icon)
@@ -165,7 +172,11 @@ export function createTray() {
export function destroyTray() {
if (tray) {
logger.info('销毁托盘图标')
tray.destroy()
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']) {
configWindow.loadURL(process.env['ELECTRON_RENDERER_URL'] + '/#/config')