diff --git a/src/components/setting/mods/clash-core-viewer.tsx b/src/components/setting/mods/clash-core-viewer.tsx index 8d05898423e84b031dbf8740c8a4a4ff229e5f98..ecef0a66ded22953dcce9aa51291c7ad9969967a 100644 --- a/src/components/setting/mods/clash-core-viewer.tsx +++ b/src/components/setting/mods/clash-core-viewer.tsx @@ -5,8 +5,15 @@ import { useTranslation } from "react-i18next"; import { useVerge } from "@/hooks/use-verge"; import { useLockFn } from "ahooks"; import { Lock } from "@mui/icons-material"; -import { IconButton, List, ListItemButton, ListItemText } from "@mui/material"; -import { changeClashCore } from "@/services/cmds"; +import { + Box, + Button, + IconButton, + List, + ListItemButton, + ListItemText, +} from "@mui/material"; +import { changeClashCore, restartSidecar } from "@/services/cmds"; import { closeAllConnections } from "@/services/api"; import { grantPermission } from "@/services/cmds"; 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 ( <BaseDialog 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={{ pb: 0, width: 320, diff --git a/src/locales/en.json b/src/locales/en.json index 573e5f8ea231e863b1bbc72168ea6f6acd8fb409..f43abdc14e3337869504ef66f1fe29713e10c57d 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -91,6 +91,7 @@ "Clash Field": "Clash Field", "Runtime Config": "Runtime Config", "ReadOnly": "ReadOnly", + "Restart": "Restart", "Back": "Back", "Save": "Save", diff --git a/src/locales/zh.json b/src/locales/zh.json index b64ce7a36307241d2426066da96bc8aecd8e695b..950ebf77921464d905414b3a52d72ab41f3e313a 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -95,6 +95,7 @@ "Clash Field": "Clash å—段", "Runtime Config": "è¿è¡Œé…ç½®", "ReadOnly": "åªè¯»", + "Restart": "é‡å¯å†…æ ¸", "Back": "返回", "Save": "ä¿å˜",