Skip to content

DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.

feat(shell): frameless window with custom top drag bar and window controls

hairyfb960cd786ebe
diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json
index 22008d65..3b2fb1f9 100644
--- a/src-tauri/capabilities/default.json
+++ b/src-tauri/capabilities/default.json
@@ -12,9 +12,12 @@
"core:window:default",
"core:window:allow-show",
"core:window:allow-hide",
+ "core:window:allow-minimize",
+ "core:window:allow-maximize",
"core:window:allow-set-focus",
"core:window:allow-unminimize",
"core:window:allow-unmaximize",
+ "core:window:allow-start-dragging",
"opener:default",
"opener:allow-open-url",
"opener:allow-default-urls",
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index 2da7cef5..1e9f6b3d 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -19,7 +19,8 @@
"minHeight": 620,
"resizable": true,
"fullscreen": false,
- "maximized": false
+ "maximized": false,
+ "decorations": false
}
],
"security": {
diff --git a/src/App.tsx b/src/App.tsx
index fe21123f..624e81a9 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,7 +1,7 @@
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { invoke } from "@tauri-apps/api/core";
import { listen, UnlistenFn } from "@tauri-apps/api/event";
-import { Wrench } from "lucide-react";
+import WindowControls from "./components/WindowControls";
import SetupScreen, { InstallProgress, SetupStatus } from "./components/SetupScreen";
import SidebarPanel from "./components/SidebarPanel";
import { useI18n } from "./i18n/context";
@@ -287,15 +287,7 @@ export default function App() {
onRetry={boot}
/>
</main>
- <button
- onClick={handleToggleSidebar}
- title={t("ui.settings")}
- className={`fixed top-4 z-40 flex h-9 w-9 cursor-pointer items-center justify-center rounded-md border border-line bg-panel2 text-ink shadow-lg transition-all duration-200 hover:bg-panel-hover ${
- sidebarOpen ? "right-[316px]" : "right-4"
- }`}
- >
- <Wrench className="h-[18px] w-[18px]" />
- </button>
+ <WindowControls sidebarOpen={sidebarOpen} onToggleSidebar={handleToggleSidebar} />
<SidebarPanel
open={sidebarOpen}
serviceRunning={serviceRunning}
@@ -322,6 +314,7 @@ export default function App() {
onRetry={boot}
/>
</main>
+ <WindowControls sidebarOpen={sidebarOpen} onToggleSidebar={handleToggleSidebar} />
</div>
);
}
@@ -378,15 +371,7 @@ export default function App() {
</button>
</div>
)}
- <button
- onClick={handleToggleSidebar}
- title={t("ui.settings")}
- className={`fixed top-4 z-40 flex h-9 w-9 cursor-pointer items-center justify-center rounded-md border border-line bg-panel2 text-ink shadow-lg transition-all duration-200 hover:bg-panel-hover ${
- sidebarOpen ? "right-[316px]" : "right-4"
- }`}
- >
- <Wrench className="h-[18px] w-[18px]" />
- </button>
+ <WindowControls sidebarOpen={sidebarOpen} onToggleSidebar={handleToggleSidebar} />
<SidebarPanel
open={sidebarOpen}
serviceRunning={serviceRunning}
diff --git a/src/components/SidebarPanel.tsx b/src/components/SidebarPanel.tsx
index ef95dea3..50e72291 100644
--- a/src/components/SidebarPanel.tsx
+++ b/src/components/SidebarPanel.tsx
@@ -135,7 +135,7 @@ export default function SidebarPanel({
return (
<aside
- className={`fixed inset-y-0 right-0 z-30 flex w-[300px] flex-col overflow-y-auto border-l border-line bg-panel shadow-2xl transition-transform duration-200 ease-out ${
+ className={`fixed top-14.5 right-0 bottom-0 z-30 flex w-[300px] flex-col overflow-y-auto border-l border-t rounded-md border-line bg-panel shadow-2xl transition-transform duration-200 ease-out ${
open ? "translate-x-0" : "translate-x-full"
}`}
>
diff --git a/src/components/WindowControls.tsx b/src/components/WindowControls.tsx
new file mode 100644
index 00000000..c244c102
--- /dev/null
+++ b/src/components/WindowControls.tsx
@@ -0,0 +1,101 @@
+import { useEffect, useMemo, useState } from "react";
+import { getCurrentWindow } from "@tauri-apps/api/window";
+import { Copy, Minus, Square, Wrench, X } from "lucide-react";
+import { useI18n } from "../i18n/context";
+
+const btn =
+ "flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-ink transition-colors hover:bg-panel-hover";
+
+interface WindowControlsProps {
+ sidebarOpen: boolean;
+ onToggleSidebar: () => void;
+}
+
+/**
+ * 右上角浮动窗口控制条(隐藏/最大化/关闭 + 侧边栏开关)。
+ *
+ * 参考 damn-reports 的自定义标题栏:去掉系统边框后,把窗口控制放到
+ * 右侧侧边栏按钮所在的位置,内嵌 dsh 页面保持全窗口显示;
+ * 半透明面板浮于其上并跟随 dsh 主题切换,视觉上与内部应用融为一体。
+ * 左侧握把(data-tauri-drag-region="deep")用于拖动窗口,双击可最大化。
+ */
+export default function WindowControls({ sidebarOpen, onToggleSidebar }: WindowControlsProps) {
+ const { t } = useI18n();
+ const appWindow = useMemo(() => getCurrentWindow(), []);
+ const [maximized, setMaximized] = useState(false);
+
+ useEffect(() => {
+ let disposed = false;
+ const sync = async () => {
+ try {
+ const next = await appWindow.isMaximized();
+ if (!disposed) setMaximized(next);
+ } catch (err) {
+ console.error("[WindowControls] failed to read maximized state:", err);
+ }
+ };
+ void sync();
+
+ let unlisten: (() => void) | null = null;
+ appWindow
+ .onResized(() => {
+ void sync();
+ })
+ .then((fn) => {
+ if (disposed) fn();
+ else unlisten = fn;
+ })
+ .catch((err) => console.error("[WindowControls] failed to watch resize:", err));
+
+ return () => {
+ disposed = true;
+ unlisten?.();
+ };
+ }, [appWindow]);
+
+ const handleMinimize = () => {
+ void appWindow.minimize();
+ };
+
+ const handleMaximize = async () => {
+ if (await appWindow.isMaximized()) {
+ await appWindow.unmaximize();
+ } else {
+ await appWindow.maximize();
+ }
+ };
+
+ // 与 damn-reports 一致:关闭按钮隐藏到托盘(Rust 侧 CloseRequested 同样处理)
+ const handleClose = () => {
+ void appWindow.hide();
+ };
+
+ return (
+ <>
+ {/* 顶部整条拖拽区域:全宽覆盖窗口顶部,双击可最大化;按钮不在这层里 */}
+ <div data-tauri-drag-region className="fixed w-[410px] top-0 z-40 h-6" />
+ <div data-tauri-drag-region className="fixed inset-x-0 left-[410px] top-0 z-40 h-12" />
+ <div className="fixed top-2 right-2 z-50">
+ <div className="flex items-center gap-0.5 rounded-lg border border-line bg-panel/80 p-1 backdrop-blur-md">
+ <button
+ className={btn}
+ onClick={onToggleSidebar}
+ title={sidebarOpen ? t("app.collapse_sidebar") : t("app.expand_sidebar")}
+ >
+ <Wrench className="size-3.5" />
+ </button>
+ <span className="mx-0.5 h-4 w-px bg-line" />
+ <button className={btn} onClick={handleMinimize} title={t("ui.minimize")}>
+ <Minus className="size-3.5" />
+ </button>
+ <button className={btn} onClick={handleMaximize} title={maximized ? t("ui.restore") : t("ui.maximize")}>
+ {maximized ? <Copy className="size-3" /> : <Square className="size-3" />}
+ </button>
+ <button className={`${btn} hover:bg-danger`} onClick={handleClose} title={t("ui.close")}>
+ <X className="size-3.5" />
+ </button>
+ </div>
+ </div>
+ </>
+ );
+}
diff --git a/src/i18n/en.ts b/src/i18n/en.ts
index a3578045..efe42c8c 100644
--- a/src/i18n/en.ts
+++ b/src/i18n/en.ts
@@ -60,6 +60,11 @@ export const en: Translations = {
running: "Running",
stopped: "Stopped",
settings: "Settings",
+ minimize: "Minimize",
+ maximize: "Maximize",
+ restore: "Restore",
+ close: "Close",
+ drag_window: "Drag window, double-click to maximize",
waiting_logs: "Waiting for installation logs...",
install_log: "Installation log",
},
diff --git a/src/i18n/types.ts b/src/i18n/types.ts
index c7c84889..5585bcfd 100644
--- a/src/i18n/types.ts
+++ b/src/i18n/types.ts
@@ -60,6 +60,11 @@ export interface Translations {
running: string;
stopped: string;
settings: string;
+ minimize: string;
+ maximize: string;
+ restore: string;
+ close: string;
+ drag_window: string;
waiting_logs: string;
install_log: string;
};
diff --git a/src/i18n/zh.ts b/src/i18n/zh.ts
index 777fb70a..e0b2f8e7 100644
--- a/src/i18n/zh.ts
+++ b/src/i18n/zh.ts
@@ -60,6 +60,11 @@ export const zh: Translations = {
running: "运行中",
stopped: "已停止",
settings: "设置",
+ minimize: "最小化",
+ maximize: "最大化",
+ restore: "还原",
+ close: "关闭",
+ drag_window: "拖动窗口,双击最大化",
waiting_logs: "等待安装日志...",
install_log: "安装日志",
},