feat: add restart core button
This commit is contained in:
parent
66d93ea037
commit
9a29c9abdd
@ -5,8 +5,15 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { useVerge } from "@/hooks/use-verge";
|
import { useVerge } from "@/hooks/use-verge";
|
||||||
import { useLockFn } from "ahooks";
|
import { useLockFn } from "ahooks";
|
||||||
import { Lock } from "@mui/icons-material";
|
import { Lock } from "@mui/icons-material";
|
||||||
import { IconButton, List, ListItemButton, ListItemText } from "@mui/material";
|
import {
|
||||||
import { changeClashCore } from "@/services/cmds";
|
Box,
|
||||||
|
Button,
|
||||||
|
IconButton,
|
||||||
|
List,
|
||||||
|
ListItemButton,
|
||||||
|
ListItemText,
|
||||||
|
} from "@mui/material";
|
||||||
|
import { changeClashCore, restartSidecar } from "@/services/cmds";
|
||||||
import { closeAllConnections } from "@/services/api";
|
import { closeAllConnections } from "@/services/api";
|
||||||
import { grantPermission } from "@/services/cmds";
|
import { grantPermission } from "@/services/cmds";
|
||||||
import getSystem from "@/utils/get-system";
|
import getSystem from "@/utils/get-system";
|
||||||
@ -58,10 +65,27 @@ export const ClashCoreViewer = forwardRef<DialogRef>((props, ref) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const onRestart = useLockFn(async () => {
|
||||||
|
try {
|
||||||
|
await restartSidecar();
|
||||||
|
Notice.success(`Successfully restart core`, 1000);
|
||||||
|
} catch (err: any) {
|
||||||
|
Notice.error(err?.message || err.toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BaseDialog
|
<BaseDialog
|
||||||
open={open}
|
open={open}
|
||||||
title={t("Clash Core")}
|
title={
|
||||||
|
<Box display="flex" justifyContent="space-between">
|
||||||
|
{t("Clash Core")}
|
||||||
|
|
||||||
|
<Button variant="contained" size="small" onClick={onRestart}>
|
||||||
|
{t("Restart")}
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
}
|
||||||
contentSx={{
|
contentSx={{
|
||||||
pb: 0,
|
pb: 0,
|
||||||
width: 320,
|
width: 320,
|
||||||
|
@ -91,6 +91,7 @@
|
|||||||
"Clash Field": "Clash Field",
|
"Clash Field": "Clash Field",
|
||||||
"Runtime Config": "Runtime Config",
|
"Runtime Config": "Runtime Config",
|
||||||
"ReadOnly": "ReadOnly",
|
"ReadOnly": "ReadOnly",
|
||||||
|
"Restart": "Restart",
|
||||||
|
|
||||||
"Back": "Back",
|
"Back": "Back",
|
||||||
"Save": "Save",
|
"Save": "Save",
|
||||||
|
@ -95,6 +95,7 @@
|
|||||||
"Clash Field": "Clash 字段",
|
"Clash Field": "Clash 字段",
|
||||||
"Runtime Config": "运行配置",
|
"Runtime Config": "运行配置",
|
||||||
"ReadOnly": "只读",
|
"ReadOnly": "只读",
|
||||||
|
"Restart": "重启内核",
|
||||||
|
|
||||||
"Back": "返回",
|
"Back": "返回",
|
||||||
"Save": "保存",
|
"Save": "保存",
|
||||||
|
Loading…
Reference in New Issue
Block a user