Support windows theme adaptation

This commit is contained in:
Tw93
2025-08-13 20:02:43 +08:00
parent 48be7fce14
commit 90b1355aa7

View File

@@ -6,6 +6,9 @@ use tauri::{App, Config, Url, WebviewUrl, WebviewWindow, WebviewWindowBuilder};
#[cfg(target_os = "macos")]
use tauri::{Theme, TitleBarStyle};
#[cfg(target_os = "windows")]
use tauri::Theme;
pub fn set_window(app: &mut App, config: &PakeConfig, tauri_config: &Config) -> WebviewWindow {
let package_name = tauri_config.clone().product_name.unwrap();
let _data_dir = get_data_dir(app.handle(), package_name);
@@ -62,11 +65,26 @@ pub fn set_window(app: &mut App, config: &PakeConfig, tauri_config: &Config) ->
}
}
#[cfg(not(target_os = "macos"))]
#[cfg(target_os = "windows")]
{
window_builder = window_builder
.data_directory(_data_dir)
.title(app.package_info().name.clone());
// Set theme to None for automatic system theme detection on Windows
// This allows the window to respond to system theme changes automatically
window_builder = window_builder.theme(None);
}
#[cfg(target_os = "linux")]
{
window_builder = window_builder
.data_directory(_data_dir)
.title(app.package_info().name.clone());
// Set theme to None for automatic system theme detection on Linux
// This allows the window to respond to system theme changes automatically
window_builder = window_builder.theme(None);
}
window_builder.build().expect("Failed to build window")