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