fix(#1203): correct types (#1207)

This commit is contained in:
Sukka 2024-06-15 19:23:58 +08:00 committed by GitHub
parent 4f5227782a
commit 455892b414

View File

@ -134,21 +134,9 @@ export const getProxies = async () => {
const { GLOBAL: global, DIRECT: direct, REJECT: reject } = proxyRecord; const { GLOBAL: global, DIRECT: direct, REJECT: reject } = proxyRecord;
interface Group { let groups: IProxyGroupItem[] = Object.values(proxyRecord).reduce<
all: IProxyItem[]; IProxyGroupItem[]
name: string; >((acc, each) => {
type: string;
udp: boolean;
xudp: boolean;
tfo: boolean;
history: {
time: string;
delay: number;
}[];
}
let groups: Group[] = Object.values(proxyRecord).reduce<Group[]>(
(acc, each) => {
if (each.name !== "GLOBAL" && each.all) { if (each.name !== "GLOBAL" && each.all) {
acc.push({ acc.push({
...each, ...each,
@ -157,12 +145,11 @@ export const getProxies = async () => {
} }
return acc; return acc;
}, }, []);
[]
);
if (global?.all) { if (global?.all) {
let globalGroups: Group[] = global.all.reduce<Group[]>((acc, name) => { let globalGroups: IProxyGroupItem[] = global.all.reduce<IProxyGroupItem[]>(
(acc, name) => {
if (proxyRecord[name]?.all) { if (proxyRecord[name]?.all) {
acc.push({ acc.push({
...proxyRecord[name], ...proxyRecord[name],
@ -170,7 +157,9 @@ export const getProxies = async () => {
}); });
} }
return acc; return acc;
}, []); },
[]
);
let globalNames = new Set(globalGroups.map((each) => each.name)); let globalNames = new Set(globalGroups.map((each) => each.name));
groups = groups groups = groups