diff --git a/src/main/services/ConfigManager.ts b/src/main/services/ConfigManager.ts index ab7f4404..2e848370 100644 --- a/src/main/services/ConfigManager.ts +++ b/src/main/services/ConfigManager.ts @@ -27,7 +27,7 @@ export class ConfigManager { } isTray(): boolean { - return !!this.store.get('tray', false) + return !!this.store.get('tray', true) } setTray(value: boolean) { diff --git a/src/main/services/TrayService.ts b/src/main/services/TrayService.ts index 80011c15..0ddadd89 100644 --- a/src/main/services/TrayService.ts +++ b/src/main/services/TrayService.ts @@ -58,7 +58,10 @@ export class TrayService { } ]) - this.tray.setContextMenu(contextMenu) + if (process.platform === 'linux') { + this.tray.setContextMenu(contextMenu) + } + this.tray.setToolTip('Cherry Studio') this.tray.on('right-click', () => { diff --git a/src/main/services/WindowService.ts b/src/main/services/WindowService.ts index 4b0de753..07384609 100644 --- a/src/main/services/WindowService.ts +++ b/src/main/services/WindowService.ts @@ -166,11 +166,10 @@ export class WindowService { } private setupWindowLifecycleEvents(mainWindow: BrowserWindow) { + if (!configManager.isTray() && isTilingWindowManager()) { + app.quit() + } mainWindow.on('close', (event) => { - if (!configManager.isTray() && isTilingWindowManager()) { - app.quit() - } - if (!app.isQuitting) { event.preventDefault() mainWindow.hide() @@ -181,7 +180,7 @@ export class WindowService { public showMainWindow() { if (this.mainWindow) { if (this.mainWindow.isMinimized()) { - this.mainWindow.restore() + return this.mainWindow.restore() } this.mainWindow.show() this.mainWindow.focus() diff --git a/src/main/utils/is-tiling-window-manager.ts b/src/main/utils/is-tiling-window-manager.ts index c481d158..7382ddbc 100644 --- a/src/main/utils/is-tiling-window-manager.ts +++ b/src/main/utils/is-tiling-window-manager.ts @@ -1,8 +1,12 @@ function isTilingWindowManager() { - if (process.platform !== 'linux') { + if (process.platform === 'darwin') { return false } + if (process.platform !== 'linux') { + return true + } + const desktopEnv = process.env.XDG_CURRENT_DESKTOP?.toLowerCase() const tilingSystems = ['hyprland', 'i3', 'sway', 'bspwm', 'dwm', 'awesome', 'qtile', 'herbstluftwm', 'xmonad'] diff --git a/src/renderer/src/i18n/locales/en-us.json b/src/renderer/src/i18n/locales/en-us.json index efe83d52..d36ab1f0 100644 --- a/src/renderer/src/i18n/locales/en-us.json +++ b/src/renderer/src/i18n/locales/en-us.json @@ -336,7 +336,7 @@ "about.license.button": "License", "about.contact.button": "Email", "proxy.title": "Proxy Address", - "tray.title": "Minimize to tray instead of closing", + "tray.title": "Show Tray Icon", "theme.title": "Theme", "theme.dark": "Dark", "theme.light": "Light", diff --git a/src/renderer/src/i18n/locales/zh-cn.json b/src/renderer/src/i18n/locales/zh-cn.json index 7625d713..e0812ba5 100644 --- a/src/renderer/src/i18n/locales/zh-cn.json +++ b/src/renderer/src/i18n/locales/zh-cn.json @@ -324,7 +324,7 @@ "about.license.button": "查看", "about.contact.button": "邮件", "proxy.title": "代理地址", - "tray.title": "最小化到托盘而不是关闭", + "tray.title": "显示任务栏图标", "theme.title": "主题", "theme.dark": "深色主题", "theme.light": "浅色主题", diff --git a/src/renderer/src/i18n/locales/zh-tw.json b/src/renderer/src/i18n/locales/zh-tw.json index b9e7eed7..de359b2c 100644 --- a/src/renderer/src/i18n/locales/zh-tw.json +++ b/src/renderer/src/i18n/locales/zh-tw.json @@ -324,7 +324,7 @@ "about.license.button": "查看", "about.contact.button": "郵件", "proxy.title": "代理地址", - "tray.title": "最小化到系統列而不是關閉", + "tray.title": "顯示工作列圖示", "theme.title": "主題", "theme.dark": "深色主題", "theme.light": "淺色主題", diff --git a/src/renderer/src/store/index.ts b/src/renderer/src/store/index.ts index f628d93b..43ee7ac1 100644 --- a/src/renderer/src/store/index.ts +++ b/src/renderer/src/store/index.ts @@ -24,7 +24,7 @@ const persistedReducer = persistReducer( { key: 'cherry-studio', storage, - version: 39, + version: 40, blacklist: ['runtime'], migrate }, diff --git a/src/renderer/src/store/migrate.ts b/src/renderer/src/store/migrate.ts index 09b1afb7..6b270539 100644 --- a/src/renderer/src/store/migrate.ts +++ b/src/renderer/src/store/migrate.ts @@ -673,6 +673,10 @@ const migrateConfig = { '39': (state: RootState) => { state.settings.codeStyle = 'auto' return state + }, + '40': (state: RootState) => { + state.settings.tray = true + return state } } diff --git a/src/renderer/src/store/settings.ts b/src/renderer/src/store/settings.ts index a9165af0..b23d4a6e 100644 --- a/src/renderer/src/store/settings.ts +++ b/src/renderer/src/store/settings.ts @@ -44,6 +44,7 @@ const initialState: SettingsState = { showMessageDivider: false, messageFont: 'system', showInputEstimatedTokens: false, + tray: true, theme: ThemeMode.auto, windowStyle: 'transparent', fontSize: 14,