mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 05:33:45 +08:00
Support upgrade alpha core
This commit is contained in:
parent
a66e8dfc9f
commit
0c3f03680c
@ -14,7 +14,7 @@ import {
|
||||
ListItemText,
|
||||
} from "@mui/material";
|
||||
import { changeClashCore, restartSidecar } from "@/services/cmds";
|
||||
import { closeAllConnections } from "@/services/api";
|
||||
import { closeAllConnections, upgradeCore } from "@/services/api";
|
||||
import { grantPermission } from "@/services/cmds";
|
||||
import getSystem from "@/utils/get-system";
|
||||
|
||||
@ -76,16 +76,36 @@ export const ClashCoreViewer = forwardRef<DialogRef>((props, ref) => {
|
||||
}
|
||||
});
|
||||
|
||||
const onUpgrade = useLockFn(async () => {
|
||||
try {
|
||||
await upgradeCore();
|
||||
Notice.success(`Successfully upgrade core`, 1000);
|
||||
} catch (err: any) {
|
||||
Notice.error(err?.response.data.message || err.toString());
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<BaseDialog
|
||||
open={open}
|
||||
title={
|
||||
<Box display="flex" justifyContent="space-between">
|
||||
{t("Clash Core")}
|
||||
|
||||
<Button variant="contained" size="small" onClick={onRestart}>
|
||||
{t("Restart")}
|
||||
</Button>
|
||||
<Box>
|
||||
{clash_core !== "clash-meta" && (
|
||||
<Button
|
||||
variant="contained"
|
||||
size="small"
|
||||
sx={{ marginRight: "8px" }}
|
||||
onClick={onUpgrade}
|
||||
>
|
||||
{t("Upgrade")}
|
||||
</Button>
|
||||
)}
|
||||
<Button variant="contained" size="small" onClick={onRestart}>
|
||||
{t("Restart")}
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
}
|
||||
contentSx={{
|
||||
|
@ -63,11 +63,7 @@ const SettingClash = ({ onError }: Props) => {
|
||||
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());
|
||||
}
|
||||
Notice.error(err?.response.data.message || err.toString());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -112,6 +112,7 @@
|
||||
"Runtime Config": "Runtime Config",
|
||||
"ReadOnly": "ReadOnly",
|
||||
"Restart": "Restart",
|
||||
"Upgrade": "Upgrade",
|
||||
|
||||
"Back": "Back",
|
||||
"Save": "Save",
|
||||
|
@ -99,6 +99,7 @@
|
||||
"Runtime Config": "Используемый конфиг",
|
||||
"ReadOnly": "Только для чтения",
|
||||
"Restart": "Перезапуск",
|
||||
"Upgrade": "Обновлять",
|
||||
|
||||
"Back": "Назад",
|
||||
"Save": "Сохранить",
|
||||
|
@ -112,6 +112,7 @@
|
||||
"Runtime Config": "当前配置",
|
||||
"ReadOnly": "只读",
|
||||
"Restart": "重启内核",
|
||||
"Upgrade": "升级内核",
|
||||
|
||||
"Back": "返回",
|
||||
"Save": "保存",
|
||||
|
@ -61,6 +61,12 @@ export const updateGeoData = async () => {
|
||||
return instance.post("/configs/geo");
|
||||
};
|
||||
|
||||
/// Upgrade clash core
|
||||
export const upgradeCore = async () => {
|
||||
const instance = await getAxios();
|
||||
return instance.post("/upgrade");
|
||||
};
|
||||
|
||||
/// Get current rules
|
||||
export const getRules = async () => {
|
||||
const instance = await getAxios();
|
||||
|
Loading…
x
Reference in New Issue
Block a user