mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-27 16:22:11 +08:00
feat: watch linux theme changed (#7781)
* feat: add Linux theme change notifications and update dark-light dependency * fix: remove unused tauri Emitter import * update changelog * fix: clippy * fix: pnpm format
This commit is contained in:
@@ -40,6 +40,8 @@ pub fn resolve_setup_sync() {
|
||||
AsyncHandler::spawn(|| async {
|
||||
AsyncHandler::spawn_blocking(init_scheme);
|
||||
AsyncHandler::spawn_blocking(init_embed_server);
|
||||
#[cfg(target_os = "linux")]
|
||||
AsyncHandler::spawn_blocking(watch_linux_theme_changed);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -111,6 +113,30 @@ pub(super) fn init_embed_server() {
|
||||
server::embed_server();
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub(crate) fn watch_linux_theme_changed() {
|
||||
match dark_light::subscribe() {
|
||||
Ok(watcher) => {
|
||||
for mode in watcher.iter() {
|
||||
use crate::core::notification;
|
||||
|
||||
let theme = match mode {
|
||||
dark_light::Mode::Light => tauri::Theme::Light,
|
||||
dark_light::Mode::Dark => tauri::Theme::Dark,
|
||||
dark_light::Mode::Unspecified => tauri::Theme::Light, // fallback to light
|
||||
};
|
||||
notification::NotificationSystem::send_event(
|
||||
Handle::app_handle().clone(),
|
||||
notification::FrontendEvent::ThemeChanged { theme },
|
||||
);
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
logging_error!(Type::Setup, "Fail to watch linux theme changed: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) async fn init_resources() {
|
||||
logging_error!(Type::Setup, init::init_resources().await);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user