fix: manage global proxy correctly

This commit is contained in:
GyDi 2022-03-23 12:49:34 +08:00 committed by GitHub
parent 57c411288f
commit 502706931e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -91,8 +91,24 @@ const ProxyGlobal = (props: Props) => {
useEffect(() => { useEffect(() => {
if (groupName === "DIRECT") setNow("DIRECT"); if (groupName === "DIRECT") setNow("DIRECT");
if (groupName === "GLOBAL") setNow(curProxy || "DIRECT"); else if (groupName === "GLOBAL") {
}, [groupName, curProxy]); if (profiles) {
const current = profiles.current;
const profile = profiles.items?.find((p) => p.uid === current);
profile?.selected?.forEach((item) => {
if (item.name === "GLOBAL") {
if (item.now && item.now !== curProxy) {
updateProxy("GLOBAL", item.now).then(() => setNow(item!.now!));
mutate("getProxies");
}
}
});
}
setNow(curProxy || "DIRECT");
}
}, [groupName, curProxy, profiles]);
return ( return (
<> <>