mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-05-15 00:56:32 +08:00
fix: titlebar does not follow theme in dark mode (#903)
This commit is contained in:
@@ -954,3 +954,18 @@ fn run_windows_start_command(args: &[&str], terminal_name: &str) -> Result<(), S
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 设置窗口主题(Windows/macOS 标题栏颜色)
|
||||
/// theme: "dark" | "light" | "system"
|
||||
#[tauri::command]
|
||||
pub async fn set_window_theme(window: tauri::Window, theme: String) -> Result<(), String> {
|
||||
use tauri::Theme;
|
||||
|
||||
let tauri_theme = match theme.as_str() {
|
||||
"dark" => Some(Theme::Dark),
|
||||
"light" => Some(Theme::Light),
|
||||
_ => None, // system default
|
||||
};
|
||||
|
||||
window.set_theme(tauri_theme).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
@@ -956,6 +956,8 @@ pub fn run() {
|
||||
commands::test_proxy_url,
|
||||
commands::get_upstream_proxy_status,
|
||||
commands::scan_local_proxies,
|
||||
// Window theme control
|
||||
commands::set_window_theme,
|
||||
]);
|
||||
|
||||
let app = builder
|
||||
|
||||
Reference in New Issue
Block a user