mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35: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,21 +223,23 @@ export const CurrentProxyCard = () => {
|
||||
(g: { name: string }) => g.name === prev.selection.group,
|
||||
);
|
||||
|
||||
// 如果当前组不存在或为空,自动选择第一个组
|
||||
// 如果当前组不存在或为空,自动选择第一个 selector 类型的组
|
||||
if (!currentGroup && filteredGroups.length > 0) {
|
||||
newGroup = filteredGroups[0].name;
|
||||
const firstGroup = filteredGroups[0];
|
||||
newProxy = firstGroup.now;
|
||||
newDisplayProxy = proxies.records?.[newProxy] || null;
|
||||
const selectorGroup = filteredGroups.find((g: { type: string }) => g.type === "Selector");
|
||||
if (selectorGroup) {
|
||||
newGroup = selectorGroup.name;
|
||||
newProxy = selectorGroup.now || selectorGroup.all[0] || "";
|
||||
newDisplayProxy = proxies.records?.[newProxy] || null;
|
||||
|
||||
if (!isGlobalMode && !isDirectMode) {
|
||||
localStorage.setItem(STORAGE_KEY_GROUP, newGroup);
|
||||
if (newProxy) {
|
||||
localStorage.setItem(STORAGE_KEY_PROXY, newProxy);
|
||||
if (!isGlobalMode && !isDirectMode) {
|
||||
localStorage.setItem(STORAGE_KEY_GROUP, newGroup);
|
||||
if (newProxy) {
|
||||
localStorage.setItem(STORAGE_KEY_PROXY, newProxy);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (currentGroup) {
|
||||
newProxy = currentGroup.now;
|
||||
newProxy = currentGroup.now || currentGroup.all[0] || "";
|
||||
newDisplayProxy = proxies.records?.[newProxy] || null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user