mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 00:35:38 +08:00
feat: Support both registry and api for windows sysproxy
This commit is contained in:
@@ -11,11 +11,15 @@ 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();
|
||||
|
||||
@@ -31,12 +35,14 @@ 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, () => ({
|
||||
@@ -46,6 +52,7 @@ 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));
|
||||
},
|
||||
@@ -69,6 +76,9 @@ 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);
|
||||
@@ -82,7 +92,7 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
<BaseDialog
|
||||
open={open}
|
||||
title={t("System Proxy Setting")}
|
||||
contentSx={{ width: 450, maxHeight: 300 }}
|
||||
contentSx={{ width: 450, maxHeight: 500 }}
|
||||
okBtn={t("Save")}
|
||||
cancelBtn={t("Cancel")}
|
||||
onClose={() => setOpen(false)}
|
||||
@@ -134,6 +144,27 @@ 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 }}>
|
||||
|
||||
Reference in New Issue
Block a user