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