fix: auto proxy changed by guard

This commit is contained in:
MystiPanda
2024-05-26 19:07:14 +08:00
Unverified
parent b9ec94d835
commit a88d149dad
3 changed files with 81 additions and 62 deletions

View File

@@ -18,7 +18,7 @@ import { BaseDialog, DialogRef, Notice, Switch } from "@/components/base";
import { Edit } from "@mui/icons-material";
import { EditorViewer } from "@/components/profile/editor-viewer";
const DEFAULT_PAC = `function FindProxyForURL(url, host) {
return "PROXY 127.0.0.1:%mixed-port%; SOCKS5 127.0.0.1:%mixed-port%; DIRECT;"
return "PROXY 127.0.0.1:%mixed-port%; SOCKS5 127.0.0.1:%mixed-port%; DIRECT;";
}`;
export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
@@ -196,7 +196,11 @@ export const SysproxyViewer = forwardRef<DialogRef>((props, ref) => {
open={editorOpen}
language="javascript"
onChange={(content) => {
setValue((v) => ({ ...v, pac_content: content ?? "" }));
let pac = DEFAULT_PAC;
if (content && content.trim().length > 0) {
pac = content;
}
setValue((v) => ({ ...v, pac_content: pac }));
}}
onClose={() => {
setEditorOpen(false);