fix: simply compatible with proxy providers
This commit is contained in:
parent
b91daebd92
commit
08fa5205b0
@ -96,20 +96,26 @@ export async function getProxies() {
|
|||||||
|
|
||||||
let groups: ApiType.ProxyGroupItem[] = [];
|
let groups: ApiType.ProxyGroupItem[] = [];
|
||||||
|
|
||||||
|
// compatible with proxy-providers
|
||||||
|
const generateItem = (name: string) => {
|
||||||
|
if (records[name]) return records[name];
|
||||||
|
return { name, type: "unknown", udp: false, history: [] };
|
||||||
|
};
|
||||||
|
|
||||||
if (order) {
|
if (order) {
|
||||||
groups = order
|
groups = order
|
||||||
.filter((name) => records[name]?.all)
|
.filter((name) => records[name]?.all)
|
||||||
.map((name) => records[name])
|
.map((name) => records[name])
|
||||||
.map((each) => ({
|
.map((each) => ({
|
||||||
...each,
|
...each,
|
||||||
all: each.all!.map((item) => records[item]),
|
all: each.all!.map((item) => generateItem(item)),
|
||||||
}));
|
}));
|
||||||
} else {
|
} else {
|
||||||
groups = Object.values(records)
|
groups = Object.values(records)
|
||||||
.filter((each) => each.name !== "GLOBAL" && each.all)
|
.filter((each) => each.name !== "GLOBAL" && each.all)
|
||||||
.map((each) => ({
|
.map((each) => ({
|
||||||
...each,
|
...each,
|
||||||
all: each.all!.map((item) => records[item]),
|
all: each.all!.map((item) => generateItem(item)),
|
||||||
}));
|
}));
|
||||||
groups.sort((a, b) => b.name.localeCompare(a.name));
|
groups.sort((a, b) => b.name.localeCompare(a.name));
|
||||||
}
|
}
|
||||||
@ -122,3 +128,10 @@ export async function getProxies() {
|
|||||||
|
|
||||||
return { global, direct, groups, records, proxies };
|
return { global, direct, groups, records, proxies };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: get proxy providers
|
||||||
|
export async function getProviders() {
|
||||||
|
const instance = await getAxios();
|
||||||
|
const response = await instance.get<any, any>("/providers/proxies");
|
||||||
|
return response.providers as any;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user