mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 05:03:45 +08:00
parent
bb239cba2a
commit
bb985f826e
@ -1,5 +1,6 @@
|
|||||||
import { useRef } from "react";
|
import { useRef } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { useLockFn } from "ahooks";
|
||||||
import {
|
import {
|
||||||
TextField,
|
TextField,
|
||||||
Switch,
|
Switch,
|
||||||
@ -22,6 +23,7 @@ import { ClashCoreViewer } from "./mods/clash-core-viewer";
|
|||||||
import { invoke_uwp_tool } from "@/services/cmds";
|
import { invoke_uwp_tool } from "@/services/cmds";
|
||||||
import getSystem from "@/utils/get-system";
|
import getSystem from "@/utils/get-system";
|
||||||
import { useVerge } from "@/hooks/use-verge";
|
import { useVerge } from "@/hooks/use-verge";
|
||||||
|
import { updateGeoData } from "@/services/api";
|
||||||
|
|
||||||
const isWIN = getSystem() === "windows";
|
const isWIN = getSystem() === "windows";
|
||||||
|
|
||||||
@ -33,7 +35,6 @@ const SettingClash = ({ onError }: Props) => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const { clash, version, mutateClash, patchClash } = useClash();
|
const { clash, version, mutateClash, patchClash } = useClash();
|
||||||
|
|
||||||
const { verge, mutateVerge, patchVerge } = useVerge();
|
const { verge, mutateVerge, patchVerge } = useVerge();
|
||||||
|
|
||||||
const { ipv6, "allow-lan": allowLan, "log-level": logLevel } = clash ?? {};
|
const { ipv6, "allow-lan": allowLan, "log-level": logLevel } = clash ?? {};
|
||||||
@ -57,6 +58,19 @@ const SettingClash = ({ onError }: Props) => {
|
|||||||
const onChangeVerge = (patch: Partial<IVergeConfig>) => {
|
const onChangeVerge = (patch: Partial<IVergeConfig>) => {
|
||||||
mutateVerge({ ...verge, ...patch }, false);
|
mutateVerge({ ...verge, ...patch }, false);
|
||||||
};
|
};
|
||||||
|
const onUpdateGeo = useLockFn(async () => {
|
||||||
|
try {
|
||||||
|
await updateGeoData();
|
||||||
|
Notice.success("Start update geodata");
|
||||||
|
} catch (err: any) {
|
||||||
|
if (err.response.status === 400) {
|
||||||
|
Notice.success("Updating geodata...");
|
||||||
|
} else {
|
||||||
|
Notice.error(err.message || err.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SettingList title={t("Clash Setting")}>
|
<SettingList title={t("Clash Setting")}>
|
||||||
<WebUIViewer ref={webRef} />
|
<WebUIViewer ref={webRef} />
|
||||||
@ -209,6 +223,17 @@ const SettingClash = ({ onError }: Props) => {
|
|||||||
</IconButton>
|
</IconButton>
|
||||||
</SettingItem>
|
</SettingItem>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<SettingItem label={t("Update GeoData")}>
|
||||||
|
<IconButton
|
||||||
|
color="inherit"
|
||||||
|
size="small"
|
||||||
|
sx={{ my: "2px" }}
|
||||||
|
onClick={onUpdateGeo}
|
||||||
|
>
|
||||||
|
<ArrowForward />
|
||||||
|
</IconButton>
|
||||||
|
</SettingItem>
|
||||||
</SettingList>
|
</SettingList>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -80,6 +80,7 @@
|
|||||||
"System Proxy": "System Proxy",
|
"System Proxy": "System Proxy",
|
||||||
"System Proxy Setting": "System Proxy Setting",
|
"System Proxy Setting": "System Proxy Setting",
|
||||||
"Open UWP tool": "Open UWP tool",
|
"Open UWP tool": "Open UWP tool",
|
||||||
|
"Update GeoData": "Update GeoData",
|
||||||
"Proxy Guard": "Proxy Guard",
|
"Proxy Guard": "Proxy Guard",
|
||||||
"Guard Duration": "Guard Duration",
|
"Guard Duration": "Guard Duration",
|
||||||
"Proxy Bypass": "Proxy Bypass",
|
"Proxy Bypass": "Proxy Bypass",
|
||||||
|
@ -74,6 +74,7 @@
|
|||||||
"System Proxy": "Системный прокси",
|
"System Proxy": "Системный прокси",
|
||||||
"System Proxy Setting": "Настройка системного прокси",
|
"System Proxy Setting": "Настройка системного прокси",
|
||||||
"Open UWP tool": "Открыть UWP инструмент",
|
"Open UWP tool": "Открыть UWP инструмент",
|
||||||
|
"Update GeoData": "Обновление GeoData",
|
||||||
"Proxy Guard": "Защита прокси",
|
"Proxy Guard": "Защита прокси",
|
||||||
"Guard Duration": "Период защиты",
|
"Guard Duration": "Период защиты",
|
||||||
"Proxy Bypass": "Игнорирование прокси",
|
"Proxy Bypass": "Игнорирование прокси",
|
||||||
|
@ -80,6 +80,7 @@
|
|||||||
"System Proxy": "系统代理",
|
"System Proxy": "系统代理",
|
||||||
"System Proxy Setting": "系统代理设置",
|
"System Proxy Setting": "系统代理设置",
|
||||||
"Open UWP tool": "UWP工具",
|
"Open UWP tool": "UWP工具",
|
||||||
|
"Update GeoData": "更新 GeoData",
|
||||||
"Proxy Guard": "系统代理守卫",
|
"Proxy Guard": "系统代理守卫",
|
||||||
"Guard Duration": "代理守卫间隔",
|
"Guard Duration": "代理守卫间隔",
|
||||||
"Proxy Bypass": "代理绕过",
|
"Proxy Bypass": "代理绕过",
|
||||||
|
@ -55,6 +55,12 @@ export const updateConfigs = async (config: Partial<IConfigData>) => {
|
|||||||
return instance.patch("/configs", config);
|
return instance.patch("/configs", config);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Update geo data
|
||||||
|
export const updateGeoData = async () => {
|
||||||
|
const instance = await getAxios();
|
||||||
|
return instance.post("/configs/geo");
|
||||||
|
};
|
||||||
|
|
||||||
/// Get current rules
|
/// Get current rules
|
||||||
export const getRules = async () => {
|
export const getRules = async () => {
|
||||||
const instance = await getAxios();
|
const instance = await getAxios();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user