mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-19 10:22:07 +08:00
feat(home): follow url-test/fallback groups picked on the node card
The card lists fallback groups again, and switching it to a url-test or fallback group points the first select group at it without fixing a node.
This commit is contained in:
@@ -27,6 +27,12 @@ pub async fn switch_proxy_node(group_name: String, proxy_name: String, unfix: bo
|
||||
.stringify_err()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
#[specta::specta]
|
||||
pub async fn follow_proxy_group(group_name: String) {
|
||||
crate::feat::follow_proxy_group(&group_name).await;
|
||||
}
|
||||
|
||||
fn runtime_group_order(config: Option<&Mapping>) -> Vec<String> {
|
||||
let mut seen = HashSet::new();
|
||||
|
||||
|
||||
@@ -137,6 +137,21 @@ pub async fn switch_proxy_node(group_name: &str, proxy_name: &str, unfix: bool)
|
||||
{
|
||||
stale_proxies.push(left);
|
||||
}
|
||||
finish_proxy_switch(stale_proxies).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Lets a `url-test`/`fallback` group carry rule traffic without fixing a node in it.
|
||||
pub async fn follow_proxy_group(group_name: &str) {
|
||||
let Some(left) = follow_group_selection(group_name).await else {
|
||||
return;
|
||||
};
|
||||
let auto_close = Config::verge().await.data_arc().auto_close_connection.unwrap_or(false);
|
||||
finish_proxy_switch(auto_close.then_some(left).into_iter().collect()).await;
|
||||
}
|
||||
|
||||
async fn finish_proxy_switch(stale_proxies: Vec<std::string::String>) {
|
||||
let mihomo = handle::Handle::mihomo();
|
||||
announce(Refresh::Proxies);
|
||||
|
||||
if !stale_proxies.is_empty() {
|
||||
@@ -179,7 +194,6 @@ pub async fn switch_proxy_node(group_name: &str, proxy_name: &str, unfix: bool)
|
||||
"Failed to refresh tray after switching proxy: {err:#}"
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn should_update_profile(uid: &str, ignore_auto_update: bool) -> Result<Option<(String, Option<PrfOption>)>> {
|
||||
|
||||
@@ -47,6 +47,7 @@ pub fn builder() -> tauri_specta::Builder<tauri::Wry> {
|
||||
cmd::copy_clash_env,
|
||||
cmd::record_selected_node,
|
||||
cmd::switch_proxy_node,
|
||||
cmd::follow_proxy_group,
|
||||
cmd::save_dns_config,
|
||||
cmd::apply_dns_config,
|
||||
cmd::set_dns_override,
|
||||
|
||||
Reference in New Issue
Block a user