feat: script mode

This commit is contained in:
GyDi 2022-05-16 20:18:56 +08:00 committed by GitHub
parent a5434360bc
commit 61e7df77a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View File

@ -13,6 +13,7 @@
"rule": "rule", "rule": "rule",
"global": "global", "global": "global",
"direct": "direct", "direct": "direct",
"script": "script",
"Profiles": "Profiles", "Profiles": "Profiles",
"Profile URL": "Profile URL", "Profile URL": "Profile URL",
"Import": "Import", "Import": "Import",

View File

@ -13,6 +13,7 @@
"rule": "规则", "rule": "规则",
"global": "全局", "global": "全局",
"direct": "直连", "direct": "直连",
"script": "脚本",
"Profiles": "配置", "Profiles": "配置",
"Profile URL": "配置文件链接", "Profile URL": "配置文件链接",
"Import": "导入", "Import": "导入",

View File

@ -16,7 +16,7 @@ const ProxyPage = () => {
const { data: proxiesData } = useSWR("getProxies", getProxies); const { data: proxiesData } = useSWR("getProxies", getProxies);
const { data: clashConfig } = useSWR("getClashConfig", getClashConfig); const { data: clashConfig } = useSWR("getClashConfig", getClashConfig);
const modeList = ["rule", "global", "direct"]; const modeList = ["rule", "global", "direct", "script"];
const curMode = clashConfig?.mode.toLowerCase(); const curMode = clashConfig?.mode.toLowerCase();
const { groups = [], proxies = [] } = proxiesData ?? {}; const { groups = [], proxies = [] } = proxiesData ?? {};
@ -38,7 +38,8 @@ const ProxyPage = () => {
}); });
// difference style // difference style
const showGroup = curMode === "rule" && !!groups.length; const showGroup =
(curMode === "rule" || curMode === "script") && !!groups.length;
const pageStyle = showGroup ? {} : { height: "100%" }; const pageStyle = showGroup ? {} : { height: "100%" };
const paperStyle: any = showGroup const paperStyle: any = showGroup
? { mb: 0.5 } ? { mb: 0.5 }
@ -64,7 +65,7 @@ const ProxyPage = () => {
} }
> >
<Paper sx={{ borderRadius: 1, boxShadow: 2, ...paperStyle }}> <Paper sx={{ borderRadius: 1, boxShadow: 2, ...paperStyle }}>
{curMode === "rule" && !!groups.length && ( {(curMode === "rule" || curMode === "script") && !!groups.length && (
<List> <List>
{groups.map((group) => ( {groups.map((group) => (
<ProxyGroup key={group.name} group={group} /> <ProxyGroup key={group.name} group={group} />