From 76f9db851636f3311c222187f161ebf287b9669c Mon Sep 17 00:00:00 2001 From: MystiPanda Date: Thu, 14 Dec 2023 11:24:16 +0800 Subject: [PATCH] chore: Optimize upgrade process --- .../setting/mods/clash-core-viewer.tsx | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/components/setting/mods/clash-core-viewer.tsx b/src/components/setting/mods/clash-core-viewer.tsx index eeb42f29..3455508b 100644 --- a/src/components/setting/mods/clash-core-viewer.tsx +++ b/src/components/setting/mods/clash-core-viewer.tsx @@ -4,7 +4,8 @@ import { BaseDialog, DialogRef, Notice } from "@/components/base"; import { useTranslation } from "react-i18next"; import { useVerge } from "@/hooks/use-verge"; import { useLockFn } from "ahooks"; -import { Lock } from "@mui/icons-material"; +import { LoadingButton } from "@mui/lab"; +import { SwitchAccessShortcut, RestartAlt } from "@mui/icons-material"; import { Box, Button, @@ -31,6 +32,7 @@ export const ClashCoreViewer = forwardRef((props, ref) => { const { verge, mutateVerge } = useVerge(); const [open, setOpen] = useState(false); + const [upgrading, setUpgrading] = useState(false); useImperativeHandle(ref, () => ({ open: () => setOpen(true), @@ -78,9 +80,12 @@ export const ClashCoreViewer = forwardRef((props, ref) => { const onUpgrade = useLockFn(async () => { try { + setUpgrading(true); await upgradeCore(); + setUpgrading(false); Notice.success(`Successfully upgrade core`, 1000); } catch (err: any) { + setUpgrading(false); Notice.error(err?.response.data.message || err.toString()); } }); @@ -93,16 +98,24 @@ export const ClashCoreViewer = forwardRef((props, ref) => { {t("Clash Core")} {clash_core !== "clash-meta" && ( - + )} - @@ -110,7 +123,7 @@ export const ClashCoreViewer = forwardRef((props, ref) => { } contentSx={{ pb: 0, - width: 320, + width: 400, height: 180, overflowY: "auto", userSelect: "text",