25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(desktop): keep macOS icon independent from app theme
t8y2e250ed300130
diff --git a/apps/desktop/src/composables/__tests__/useTheme.spec.ts b/apps/desktop/src/composables/__tests__/useTheme.spec.tsindex 79cfa7c1f0..05c695d656 100644--- a/apps/desktop/src/composables/__tests__/useTheme.spec.ts+++ b/apps/desktop/src/composables/__tests__/useTheme.spec.ts@@ -51,7 +51,7 @@ async function flushDynamicImport() {await new Promise((resolve) => setTimeout(resolve, 0));}-describe("useTheme on Linux", () => {+describe("useTheme in Tauri", () => {beforeEach(() => {vi.resetModules();vi.clearAllMocks();@@ -69,6 +69,7 @@ describe("useTheme on Linux", () => {afterEach(() => {vi.doUnmock("@/lib/backend/tauriRuntime");+ vi.doUnmock("@tauri-apps/api/core");vi.doUnmock("@tauri-apps/api/window");vi.unstubAllGlobals();});@@ -108,6 +109,21 @@ describe("useTheme on Linux", () => {expect(setTheme).toHaveBeenLastCalledWith("light");});+ it("does not let macOS appearance changes override the selected app icon", async () => {+ const invoke = vi.fn(async () => {});+ vi.stubGlobal("navigator", { userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)" });+ vi.doMock("@tauri-apps/api/core", () => ({ invoke }));+ const theme = await loadTheme("light");++ theme.applyTheme();+ await flushDynamicImport();+ theme.setThemeMode("dark");+ theme.setThemeMode("light");+ await flushDynamicImport();++ expect(invoke).not.toHaveBeenCalledWith("set_macos_app_icon_appearance", expect.anything());+ });+it("previews a palette without persisting it and restores the saved palette when cancelled", async () => {const theme = await loadTheme("light");theme.setThemePalette("pearl");diff --git a/apps/desktop/src/composables/useTheme.ts b/apps/desktop/src/composables/useTheme.tsindex a2579451da..c6cd237370 100644--- a/apps/desktop/src/composables/useTheme.ts+++ b/apps/desktop/src/composables/useTheme.ts@@ -28,7 +28,6 @@ import {import { safeLocalStorageGet, safeLocalStorageSet } from "@/lib/backend/safeStorage";import { isTauriRuntime } from "@/lib/backend/tauriRuntime";import { persistAppAppearancePatch } from "@/lib/app/appAppearance";-import { isMacOS } from "@/lib/backend/platform";function isLinuxTauriRuntime() {return isTauriRuntime() && typeof navigator !== "undefined" && /linux/i.test(navigator.userAgent);@@ -101,8 +100,6 @@ function writeRootToken(cssVar: string, value: string, options?: { debounceMs?:let mediaQuery: MediaQueryList | null = null;let isListeningForSystemTheme = false;let cachedTauriWindow: typeof import("@tauri-apps/api/window") | null = null;-let macOSAppIconSyncQueue: Promise<void> = Promise.resolve();-let lastSyncedMacOSAppIconAppearance: boolean | null = null;function readSystemPrefersDark() {if (typeof window === "undefined" || typeof window.matchMedia !== "function") return false;@@ -121,24 +118,6 @@ function setupSystemThemeListener() {isListeningForSystemTheme = true;}-export function syncMacOSAppIconAppearance(isDark: boolean): Promise<void> {- if (!isTauriRuntime() || !isMacOS()) return Promise.resolve();- if (lastSyncedMacOSAppIconAppearance === isDark) return macOSAppIconSyncQueue;- lastSyncedMacOSAppIconAppearance = isDark;- macOSAppIconSyncQueue = macOSAppIconSyncQueue- .catch(() => {})- .then(async () => {- try {- const { invoke } = await import("@tauri-apps/api/core");- await invoke("set_macos_app_icon_appearance", { isDark });- } catch {- // The bundle icon can fail to persist when the installed .app is read-only.- // The Rust side logs the native failure while the running icon still updates.- }- });- return macOSAppIconSyncQueue;-}-function applyThemePalette() {if (typeof document === "undefined") return;@@ -167,11 +146,6 @@ function applyTheme() {requestAnimationFrame(() => doc.classList.remove("disable-transitions"));if (!isTauriRuntime()) return;- // Keep the persistent macOS app-bundle icon in step with the resolved app- // appearance, including system-theme changes. The backend preserves an- // explicitly selected black icon when the app is in light mode.- void syncMacOSAppIconAppearance(dark);-const tauriTheme = getTauriThemeForMode(themeMode.value);// Tauri owns the Linux GTK preference. Calling setTheme(null) here forces it// to light, so only skip the native system-theme write and keep explicit modes.diff --git a/src-tauri/src/commands/app_settings.rs b/src-tauri/src/commands/app_settings.rsindex 49c2e78e56..f605b09aeb 100644--- a/src-tauri/src/commands/app_settings.rs+++ b/src-tauri/src/commands/app_settings.rs@@ -98,25 +98,6 @@ pub async fn update_app_appearance_settings(state.storage.update_app_appearance_settings(&patch).await}-#[tauri::command]-pub async fn set_macos_app_icon_appearance(- app: AppHandle,- state: State<'_, Arc<AppState>>,- is_dark: bool,-) -> Result<(), String> {- #[cfg(target_os = "macos")]- {- let desktop_settings = state.storage.load_desktop_settings().await?;- crate::apply_macos_app_appearance_icon(&app, is_dark, desktop_settings.icon_theme)- .map_err(|error| error.to_string())- }- #[cfg(not(target_os = "macos"))]- {- let _ = (app, state, is_dark);- Ok(())- }-}-#[tauri::command]pub async fn set_app_locale(app: AppHandle,diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rsindex 79aa1f3a6c..af2c2dd8b1 100644--- a/src-tauri/src/lib.rs+++ b/src-tauri/src/lib.rs@@ -115,8 +115,6 @@ const BLACK_APP_ICON: tauri::image::Image<'_> = tauri::include_image!("icons/icoconst MACOS_DEFAULT_APP_ICON: &[u8] = include_bytes!("../icons/icon.icns");#[cfg(target_os = "macos")]const MACOS_DARK_APP_ICON: &[u8] = include_bytes!("../icons/icon-macos-dark.icns");-#[cfg(target_os = "macos")]-static MACOS_APP_APPEARANCE_DARK: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);pub(crate) fn apply_debug_log_level(debug_logging_enabled: bool) {log::set_max_level(if debug_logging_enabled { log::LevelFilter::Debug } else { log::LevelFilter::Off });@@ -1040,21 +1038,6 @@ pub(crate) fn apply_desktop_icon_theme(app: &tauri::AppHandle, icon_theme: DesktOk(())}-#[cfg(target_os = "macos")]-pub(crate) fn apply_macos_app_appearance_icon(- app: &tauri::AppHandle,- is_dark: bool,- selected_icon_theme: DesktopIconTheme,-) -> tauri::Result<()> {- MACOS_APP_APPEARANCE_DARK.store(is_dark, std::sync::atomic::Ordering::Release);- let icon_theme = if is_dark || selected_icon_theme == DesktopIconTheme::Black {- DesktopIconTheme::Black- } else {- DesktopIconTheme::Default- };- apply_macos_app_icon_theme(app, icon_theme, true)-}-fn apply_desktop_tray_icon_theme(app: &tauri::AppHandle, _icon_theme: DesktopIconTheme) -> tauri::Result<()> {if let Some(_tray) = app.tray_by_id(DESKTOP_TRAY_ID) {#[cfg(target_os = "windows")]@@ -1083,15 +1066,7 @@ fn apply_desktop_tray_icon_theme(app: &tauri::AppHandle, _icon_theme: DesktopIcopub(crate) fn apply_desktop_settings(app: &tauri::AppHandle, desktop_settings: &DesktopSettings) -> tauri::Result<()> {apply_debug_log_level(desktop_settings.debug_logging_enabled);- #[cfg(target_os = "macos")]- let icon_theme = if MACOS_APP_APPEARANCE_DARK.load(std::sync::atomic::Ordering::Acquire) {- DesktopIconTheme::Black- } else {- desktop_settings.icon_theme- };- #[cfg(not(target_os = "macos"))]- let icon_theme = desktop_settings.icon_theme;- apply_desktop_icon_theme(app, icon_theme)?;+ apply_desktop_icon_theme(app, desktop_settings.icon_theme)?;if should_setup_desktop_tray(std::env::consts::OS, desktop_settings.show_tray_icon, linux_appindicator_available()){if let Some(tray) = app.tray_by_id(DESKTOP_TRAY_ID) {@@ -1747,9 +1722,6 @@ pub fn run() {let migration_gate = Arc::new(migration_gate::MigrationGate::new(migration_ready));app.manage(migration_gate.clone());let desktop_settings = tauri::async_runtime::block_on(storage.load_desktop_settings()).unwrap_or_default();- #[cfg(target_os = "macos")]- let app_appearance =- tauri::async_runtime::block_on(storage.load_app_appearance_settings()).unwrap_or_default();app.handle().plugin(tauri_plugin_log::Builder::default().timezone_strategy(tauri_plugin_log::TimezoneStrategy::UseLocal)@@ -1901,20 +1873,6 @@ pub fn run() {) {setup_desktop_tray(app, desktop_settings.icon_theme)?;}- #[cfg(target_os = "macos")]- match app_appearance.theme_mode.as_deref() {- Some("dark" | "soft-dark") => {- apply_macos_app_appearance_icon(app.handle(), true, desktop_settings.icon_theme)?;- }- Some("light" | "soft-light") => {- apply_macos_app_appearance_icon(app.handle(), false, desktop_settings.icon_theme)?;- }- // System mode is resolved by the renderer's matchMedia listener- // as soon as startup hydration finishes. Leave the persisted- // bundle icon intact until then to avoid briefly forcing light.- _ => {}- }- #[cfg(not(target_os = "macos"))]apply_desktop_icon_theme(app.handle(), desktop_settings.icon_theme)?;#[cfg(target_os = "macos")]apply_macos_development_dock_badge(app.handle())?;@@ -2044,7 +2002,6 @@ pub fn run() {commands::app_settings::save_max_retries,commands::app_settings::load_app_appearance_settings,commands::app_settings::update_app_appearance_settings,- commands::app_settings::set_macos_app_icon_appearance,commands::app_settings::set_app_locale,commands::app_settings::complete_app_close,commands::app_settings::mark_frontend_ready,diff --git a/src-tauri/src/migration_gate.rs b/src-tauri/src/migration_gate.rsindex 1d4bc6b28e..0a1105429f 100644--- a/src-tauri/src/migration_gate.rs+++ b/src-tauri/src/migration_gate.rs@@ -46,7 +46,6 @@ pub fn allowed_command(command: &str) -> bool {| "get_platform"| "load_app_appearance_settings"| "update_app_appearance_settings"- | "set_macos_app_icon_appearance"| "set_app_locale")}@@ -69,7 +68,14 @@ mod tests {use super::*;#[test]fn gate_denies_business_commands() {- for command in ["load_connections", "webdav_sync_upload", "load_ai_config", "plugin_invoke", "migration_fake"] {+ for command in [+ "load_connections",+ "webdav_sync_upload",+ "load_ai_config",+ "plugin_invoke",+ "migration_fake",+ "set_macos_app_icon_appearance",+ ] {assert!(!allowed_command(command));}assert!(allowed_command("migration_start"));