mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-11-19 02:12:10 +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:
@@ -65,6 +65,7 @@
|
||||
- 优化连接、规则和日志筛选:切换页面后保留过滤条件
|
||||
- 优化全局模式代理列表:仅显示 `GLOBAL` 节点,选中其中的策略组时才显示该组
|
||||
- 优化设置页开关和选项所在行的鼠标悬停高亮,便于对应说明与控件
|
||||
- 优化首页「当前节点」卡片:代理组列表加入 `fallback` 代理组,切换到 `url-test` 或 `fallback` 代理组时同样联动 `select` 代理组
|
||||
|
||||
**🍎 macOS**
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -55,6 +55,7 @@ import {
|
||||
useCoreDataStatus,
|
||||
useProxiesData,
|
||||
} from '@/providers/app-data-context'
|
||||
import { followProxyGroup } from '@/services/cmds'
|
||||
import delayManager from '@/services/delay'
|
||||
import {
|
||||
findCurrentGroupMember,
|
||||
@@ -665,7 +666,7 @@ export const CurrentProxyCard = () => {
|
||||
return proxyView.groups.filter(
|
||||
(group) =>
|
||||
!group.hidden &&
|
||||
(group.type === 'Selector' || group.type === 'URLTest'),
|
||||
['Selector', 'URLTest', 'Fallback'].includes(group.type),
|
||||
)
|
||||
}, [proxyView])
|
||||
|
||||
@@ -765,6 +766,7 @@ export const CurrentProxyCard = () => {
|
||||
if (isGlobalMode || isDirectMode) return
|
||||
setLastGroupName(newGroupName)
|
||||
writeProfileScopedItem(STORAGE_KEY_GROUP, newGroupName)
|
||||
void followProxyGroup(newGroupName)
|
||||
},
|
||||
[isDirectMode, isGlobalMode, writeProfileScopedItem],
|
||||
)
|
||||
|
||||
@@ -83,6 +83,8 @@ export const commands = {
|
||||
__TAURI_INVOKE<null>('record_selected_node', { groupName, node }),
|
||||
switchProxyNode: (groupName: string, proxyName: string, unfix: boolean) =>
|
||||
__TAURI_INVOKE<null>('switch_proxy_node', { groupName, proxyName, unfix }),
|
||||
followProxyGroup: (groupName: string) =>
|
||||
__TAURI_INVOKE<void>('follow_proxy_group', { groupName }),
|
||||
saveDnsConfig: (dnsConfig: YamlMapping) =>
|
||||
__TAURI_INVOKE<null>('save_dns_config', { dnsConfig }),
|
||||
applyDnsConfig: (apply: boolean) =>
|
||||
|
||||
@@ -165,6 +165,10 @@ export async function switchProxyNode(
|
||||
return commands.switchProxyNode(groupName, proxyName, unfix)
|
||||
}
|
||||
|
||||
export async function followProxyGroup(groupName: string) {
|
||||
return commands.followProxyGroup(groupName)
|
||||
}
|
||||
|
||||
export async function getProxyView(): Promise<ProxyViewV1> {
|
||||
const view = await commands.getProxyView()
|
||||
if (view.schemaVersion !== 1) {
|
||||
|
||||
Reference in New Issue
Block a user