From 97495d1550d27c2ab0412b4fe02e1253aefb477b Mon Sep 17 00:00:00 2001 From: TinsFox Date: Mon, 22 Dec 2025 15:43:28 +0800 Subject: [PATCH] Remove macOS titlebar tint and align custom header (#438) --- src-tauri/src/lib.rs | 38 ---------------- src/App.tsx | 106 +++++++++++++++++++++++-------------------- 2 files changed, 57 insertions(+), 87 deletions(-) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 6da99ea5b..b41cb279c 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -223,44 +223,6 @@ pub fn run() { log::warn!("初始化 Updater 插件失败,已跳过:{e}"); } } - #[cfg(target_os = "macos")] - { - // 设置 macOS 标题栏背景色为主界面蓝色 - if let Some(window) = app.get_webview_window("main") { - use objc2::rc::Retained; - use objc2::runtime::AnyObject; - use objc2_app_kit::NSColor; - - match window.ns_window() { - Ok(ns_window_ptr) => { - if let Some(ns_window) = - unsafe { Retained::retain(ns_window_ptr as *mut AnyObject) } - { - // 使用与主界面 banner 相同的蓝色 #3498db - // #3498db = RGB(52, 152, 219) - let bg_color = unsafe { - NSColor::colorWithRed_green_blue_alpha( - 52.0 / 255.0, // R: 52 - 152.0 / 255.0, // G: 152 - 219.0 / 255.0, // B: 219 - 1.0, // Alpha: 1.0 - ) - }; - - unsafe { - use objc2::msg_send; - let _: () = - msg_send![&*ns_window, setBackgroundColor: &*bg_color]; - } - } else { - log::warn!("Failed to retain NSWindow reference"); - } - } - Err(e) => log::warn!("Failed to get NSWindow pointer: {e}"), - } - } - } - // 初始化日志 if cfg!(debug_assertions) { app.handle().plugin( diff --git a/src/App.tsx b/src/App.tsx index d9b730c0f..c658f0db7 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -47,6 +47,10 @@ import { Button } from "@/components/ui/button"; type View = "providers" | "settings" | "prompts" | "skills" | "mcp" | "agents"; +const DRAG_BAR_HEIGHT = 28; // px +const HEADER_HEIGHT = 64; // px +const CONTENT_TOP_OFFSET = DRAG_BAR_HEIGHT + HEADER_HEIGHT; + function App() { const { t } = useTranslation(); const queryClient = useQueryClient(); @@ -101,7 +105,7 @@ function App() { if (event.appType === activeApp) { await refetch(); } - }, + } ); } catch (error) { console.error("[App] Failed to subscribe provider switch event", error); @@ -131,7 +135,7 @@ function App() { } catch (error) { console.error( "[App] Failed to check environment conflicts on startup:", - error, + error ); } }; @@ -147,7 +151,7 @@ function App() { if (migrated) { toast.success( t("migration.success", { defaultValue: "配置迁移成功" }), - { closeButton: true }, + { closeButton: true } ); } } catch (error) { @@ -168,10 +172,10 @@ function App() { // 合并新检测到的冲突 setEnvConflicts((prev) => { const existingKeys = new Set( - prev.map((c) => `${c.varName}:${c.sourcePath}`), + prev.map((c) => `${c.varName}:${c.sourcePath}`) ); const newConflicts = conflicts.filter( - (c) => !existingKeys.has(`${c.varName}:${c.sourcePath}`), + (c) => !existingKeys.has(`${c.varName}:${c.sourcePath}`) ); return [...prev, ...newConflicts]; }); @@ -183,7 +187,7 @@ function App() { } catch (error) { console.error( "[App] Failed to check environment conflicts on app switch:", - error, + error ); } }; @@ -244,7 +248,7 @@ function App() { (p) => p.sortIndex !== undefined && p.sortIndex >= newSortIndex! && - p.id !== provider.id, + p.id !== provider.id ) .map((p) => ({ id: p.id, @@ -260,7 +264,7 @@ function App() { toast.error( t("provider.sortUpdateFailed", { defaultValue: "排序更新失败", - }), + }) ); return; // 如果排序更新失败,不继续添加 } @@ -334,7 +338,7 @@ function App() { return (
{/* 独立滚动容器 - 解决 Linux/Ubuntu 下 DndContext 与滚轮事件冲突 */} -
+
- {/* 全局拖拽区域(顶部 4px),避免上边框无法拖动 */} + {/* 全局拖拽区域(顶部 28px),避免上边框无法拖动 */}
{/* 环境变量警告横幅 */} {showEnvBanner && envConflicts.length > 0 && ( @@ -400,7 +404,7 @@ function App() { } catch (error) { console.error( "[App] Failed to re-check conflicts after deletion:", - error, + error ); } }} @@ -408,13 +412,18 @@ function App() { )}
-
@@ -430,7 +439,7 @@ function App() { onClick={() => setCurrentView("providers")} className="mr-2 rounded-lg" > - +

{currentView === "settings" && t("settings.title")} @@ -452,7 +461,7 @@ function App() { "text-xl font-semibold transition-colors", isProxyRunning && isCurrentAppTakeoverActive ? "text-emerald-500 hover:text-emerald-600 dark:text-emerald-400 dark:hover:text-emerald-300" - : "text-blue-500 hover:text-blue-600 dark:text-blue-400 dark:hover:text-blue-300", + : "text-blue-500 hover:text-blue-600 dark:text-blue-400 dark:hover:text-blue-300" )} > CC Switch @@ -464,7 +473,7 @@ function App() { title={t("common.settings")} className="hover:bg-black/5 dark:hover:bg-white/5" > - +

setCurrentView("settings")} /> @@ -483,7 +492,7 @@ function App() { className={addActionButtonClass} title={t("prompts.add")} > - + )} {currentView === "mcp" && ( @@ -493,7 +502,7 @@ function App() { className={addActionButtonClass} title={t("mcp.unifiedPanel.addServer")} > - + )} {currentView === "skills" && ( @@ -504,7 +513,7 @@ function App() { onClick={() => skillsPageRef.current?.refresh()} className="hover:bg-black/5 dark:hover:bg-white/5" > - + {t("skills.refresh")} @@ -524,7 +533,7 @@ function App() { -
+
{/* TODO: Agents 功能开发中,暂时隐藏入口 */} {/* {isClaudeApp && ( - - )} */} + + )} */}
@@ -577,7 +586,7 @@ function App() { size="icon" className={`ml-2 ${addActionButtonClass}`} > - + )} @@ -585,13 +594,12 @@ function App() {
-
- {renderContent()} +
+
+ {renderContent()} +