fix: Custom GLOBAL group display error

This commit is contained in:
MystiPanda 2024-02-11 17:59:56 +08:00
parent 51ce3a1e42
commit 5e1e09d7bf

View File

@ -107,7 +107,6 @@ export const getProxies = async () => {
getProxiesInner(), getProxiesInner(),
getProxyProviders(), getProxyProviders(),
]); ]);
// provider name map // provider name map
const providerMap = Object.fromEntries( const providerMap = Object.fromEntries(
Object.entries(providerRecord).flatMap(([provider, item]) => Object.entries(providerRecord).flatMap(([provider, item]) =>
@ -131,24 +130,27 @@ export const getProxies = async () => {
const { GLOBAL: global, DIRECT: direct, REJECT: reject } = proxyRecord; const { GLOBAL: global, DIRECT: direct, REJECT: reject } = proxyRecord;
let groups: IProxyGroupItem[] = []; let groups = Object.values(proxyRecord)
.filter((each) => each.name !== "GLOBAL" && each.all)
.map((each) => ({
...each,
all: each.all!.map((item) => generateItem(item)),
}));
if (global?.all) { if (global?.all) {
groups = global.all let globalGroups = global.all
.filter((name) => proxyRecord[name]?.all) .filter((name) => proxyRecord[name]?.all)
.map((name) => proxyRecord[name]) .map((name) => proxyRecord[name])
.map((each) => ({ .map((each) => ({
...each, ...each,
all: each.all!.map((item) => generateItem(item)), all: each.all!.map((item) => generateItem(item)),
})); }));
} else { let globalNames = globalGroups.map((each) => each.name);
groups = Object.values(proxyRecord) groups = groups
.filter((each) => each.name !== "GLOBAL" && each.all) .filter((group) => {
.map((each) => ({ return !globalNames.includes(group.name);
...each, })
all: each.all!.map((item) => generateItem(item)), .concat(globalGroups);
}))
.sort((a, b) => b.name.localeCompare(a.name));
} }
const proxies = [direct, reject].concat( const proxies = [direct, reject].concat(