mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
fix: add fallback to first proxy in group if 'now' is missing and prioritize selector-type groups
- When the current group or its 'now' field is missing, fallback to the first proxy in the group's list to ensure a valid active node is always selected. - When no current group is found, prioritize groups of type 'Selector' for selection, improving compatibility with custom or extended proxy groups.
This commit is contained in:
@@ -223,11 +223,12 @@ export const CurrentProxyCard = () => {
|
|||||||
(g: { name: string }) => g.name === prev.selection.group,
|
(g: { name: string }) => g.name === prev.selection.group,
|
||||||
);
|
);
|
||||||
|
|
||||||
// 如果当前组不存在或为空,自动选择第一个组
|
// 如果当前组不存在或为空,自动选择第一个 selector 类型的组
|
||||||
if (!currentGroup && filteredGroups.length > 0) {
|
if (!currentGroup && filteredGroups.length > 0) {
|
||||||
newGroup = filteredGroups[0].name;
|
const selectorGroup = filteredGroups.find((g: { type: string }) => g.type === "Selector");
|
||||||
const firstGroup = filteredGroups[0];
|
if (selectorGroup) {
|
||||||
newProxy = firstGroup.now;
|
newGroup = selectorGroup.name;
|
||||||
|
newProxy = selectorGroup.now || selectorGroup.all[0] || "";
|
||||||
newDisplayProxy = proxies.records?.[newProxy] || null;
|
newDisplayProxy = proxies.records?.[newProxy] || null;
|
||||||
|
|
||||||
if (!isGlobalMode && !isDirectMode) {
|
if (!isGlobalMode && !isDirectMode) {
|
||||||
@@ -236,8 +237,9 @@ export const CurrentProxyCard = () => {
|
|||||||
localStorage.setItem(STORAGE_KEY_PROXY, newProxy);
|
localStorage.setItem(STORAGE_KEY_PROXY, newProxy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (currentGroup) {
|
} else if (currentGroup) {
|
||||||
newProxy = currentGroup.now;
|
newProxy = currentGroup.now || currentGroup.all[0] || "";
|
||||||
newDisplayProxy = proxies.records?.[newProxy] || null;
|
newDisplayProxy = proxies.records?.[newProxy] || null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user