Skip to content

armgit / dbx

Public Imported from GitHub
0

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。

fix(desktop): use custom window controls on Linux

t8y2367d3682d206
diff --git a/apps/desktop/src/composables/__tests__/useWindowControls.spec.ts b/apps/desktop/src/composables/__tests__/useWindowControls.spec.ts
new file mode 100644
index 0000000000..12850155f9
--- /dev/null
+++ b/apps/desktop/src/composables/__tests__/useWindowControls.spec.ts
@@ -0,0 +1,23 @@
+import { describe, expect, it } from "vitest";
+import { shouldReserveMacTrafficLightInset, shouldShowWindowControls } from "@/composables/useWindowControls";
+
+describe("window controls", () => {
+ it("shows custom controls for non-macOS desktop windows", () => {
+ expect(shouldShowWindowControls(false, true)).toBe(true);
+ });
+
+ it("keeps macOS on native traffic lights", () => {
+ expect(shouldShowWindowControls(true, true)).toBe(false);
+ });
+
+ it("does not show desktop controls in web runtime", () => {
+ expect(shouldShowWindowControls(false, false)).toBe(false);
+ });
+
+ it("reserves traffic light inset only for non-fullscreen macOS desktop windows", () => {
+ expect(shouldReserveMacTrafficLightInset(true, false, true)).toBe(true);
+ expect(shouldReserveMacTrafficLightInset(true, true, true)).toBe(false);
+ expect(shouldReserveMacTrafficLightInset(false, false, true)).toBe(false);
+ expect(shouldReserveMacTrafficLightInset(true, false, false)).toBe(false);
+ });
+});
diff --git a/apps/desktop/src/composables/useWindowControls.ts b/apps/desktop/src/composables/useWindowControls.ts
index abc478c585..763785ad22 100644
--- a/apps/desktop/src/composables/useWindowControls.ts
+++ b/apps/desktop/src/composables/useWindowControls.ts
@@ -1,17 +1,21 @@
import { ref, onMounted, onUnmounted } from "vue";
import { isTauriRuntime } from "@/lib/tauriRuntime";
-import { isMacOS, isWindows } from "@/lib/platform";
+import { isMacOS } from "@/lib/platform";
export function shouldReserveMacTrafficLightInset(isMac: boolean, isFullscreen: boolean, isDesktop = true): boolean {
return isDesktop && isMac && !isFullscreen;
}
+export function shouldShowWindowControls(isMac: boolean, isDesktop = true): boolean {
+ return isDesktop && !isMac;
+}
+
export function useWindowControls() {
const isMaximized = ref(false);
const isFullscreen = ref(false);
const isMac = isMacOS();
const isDesktop = isTauriRuntime();
- const showControls = isDesktop && isWindows();
+ const showControls = shouldShowWindowControls(isMac, isDesktop);
let unlisten: (() => void) | null = null;
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 3d4cf078c7..436cf6cf8c 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -68,8 +68,7 @@ fn should_show_main_window_after_setup() -> bool {
fn native_window_decorations_override(target_os: &str) -> Option<bool> {
match target_os {
- "windows" => Some(false),
- "linux" => Some(true),
+ "windows" | "linux" => Some(false),
_ => None,
}
}
@@ -270,7 +269,7 @@ mod tests {
#[test]
fn overrides_native_window_decorations_for_desktop_platforms() {
assert_eq!(native_window_decorations_override("windows"), Some(false));
- assert_eq!(native_window_decorations_override("linux"), Some(true));
+ assert_eq!(native_window_decorations_override("linux"), Some(false));
assert_eq!(native_window_decorations_override("macos"), None);
}