revert: Support both registry and api for windows sysproxy

This commit is contained in:
MystiPanda
2024-01-20 12:16:46 +08:00
parent 02d89072bc
commit ef9bbaca19
9 changed files with 22 additions and 124 deletions

View File

@@ -11,15 +11,11 @@ import {
Switch,
TextField,
Typography,
Tooltip,
} from "@mui/material";
import getSystem from "@/utils/get-system";
import { useVerge } from "@/hooks/use-verge";
import { getSystemProxy } from "@/services/cmds";
import { BaseDialog, DialogRef, Notice } from "@/components/base";
const OS = getSystem();
export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
const { t } = useTranslation();
@@ -35,14 +31,12 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
enable_proxy_guard,
system_proxy_bypass,
proxy_guard_duration,
system_proxy_registry_mode,
} = verge ?? {};
const [value, setValue] = useState({
guard: enable_proxy_guard,
bypass: system_proxy_bypass,
duration: proxy_guard_duration ?? 10,
registryMode: system_proxy_registry_mode,
});
useImperativeHandle(ref, () => ({
@@ -52,7 +46,6 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
guard: enable_proxy_guard,
bypass: system_proxy_bypass,
duration: proxy_guard_duration ?? 10,
registryMode: system_proxy_registry_mode,
});
getSystemProxy().then((p) => setSysproxy(p));
},
@@ -76,9 +69,6 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
if (value.bypass !== system_proxy_bypass) {
patch.system_proxy_bypass = value.bypass;
}
if (value.registryMode !== system_proxy_registry_mode) {
patch.system_proxy_registry_mode = value.registryMode;
}
try {
await patchVerge(patch);
@@ -92,7 +82,7 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
<BaseDialog
open={open}
title={t("System Proxy Setting")}
contentSx={{ width: 450, maxHeight: 500 }}
contentSx={{ width: 450, maxHeight: 300 }}
okBtn={t("Save")}
cancelBtn={t("Cancel")}
onClose={() => setOpen(false)}
@@ -144,27 +134,6 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
}
/>
</ListItem>
{OS === "windows" && (
<Tooltip
title={
enabled
? t("Please disable the system proxy")
: t("Using the registry instead of Windows API")
}
>
<ListItem sx={{ padding: "5px 2px" }}>
<ListItemText primary={t("Use Registry")} />
<Switch
edge="end"
disabled={enabled}
checked={value.registryMode}
onChange={(_, e) =>
setValue((v) => ({ ...v, registryMode: e }))
}
/>
</ListItem>
</Tooltip>
)}
</List>
<Box sx={{ mt: 2.5 }}>