diff --git a/crates/clash-verge-widget/native/RoutingView.swift b/crates/clash-verge-widget/native/RoutingView.swift index b587f6942..7e2f1b516 100644 --- a/crates/clash-verge-widget/native/RoutingView.swift +++ b/crates/clash-verge-widget/native/RoutingView.swift @@ -195,5 +195,6 @@ struct RoutingView: View { .environment(\.layoutDirection, rtl ? .rightToLeft : .leftToRight) .transaction { $0.animation = nil } .buttonStyle(.plain) + .widgetURL(URL(string: "clash-verge://show")) } } diff --git a/src-tauri/src/utils/resolve/scheme.rs b/src-tauri/src/utils/resolve/scheme.rs index 3aae4991e..19e7ea5e9 100644 --- a/src-tauri/src/utils/resolve/scheme.rs +++ b/src-tauri/src/utils/resolve/scheme.rs @@ -8,6 +8,8 @@ use crate::{ core::{CoreManager, handle, timer::Timer}, utils::help, }; +#[cfg(target_os = "macos")] +use crate::{module::lightweight, utils::window_manager::WindowManager}; use clash_verge_logging::{Type, logging, logging_error}; pub(super) async fn resolve_scheme(param: &str) -> Result<()> { @@ -25,6 +27,19 @@ pub(super) async fn resolve_scheme(param: &str) -> Result<()> { let link_parsed = Url::parse(param_str) .map_err(|e| anyhow::anyhow!("failed to parse deep link: {e:?}, param: {masked_deep_link}"))?; + // Dedicated "raise the window" route (clash-verge://show) for surfaces that + // activate a tray-only host without firing the macOS reopen event. + #[cfg(target_os = "macos")] + if link_parsed.host_str() == Some("show") { + if lightweight::is_in_lightweight_mode() { + lightweight::exit_lightweight_mode().await; + } else { + handle::Handle::global().set_activation_policy_regular(); + WindowManager::show_main_window().await; + } + return Ok(()); + } + let Some((url, name)) = extract_subscription_info(&link_parsed) else { logging!( warn,