refactor: extract service installation logic to custom hook and optimize related component handling

This commit is contained in:
wonfen
2025-05-17 19:09:50 +08:00
parent 7556758284
commit e1d6c74e4f
19 changed files with 129 additions and 126 deletions

View File

@@ -66,7 +66,7 @@ export const ClashCoreViewer = forwardRef<DialogRef>((props, ref) => {
const onRestart = useLockFn(async () => {
try {
await restartCore();
showNotice('success', t(`Clash Core Restarted`), 1000);
showNotice('success', t(`Clash Core Restarted`));
} catch (err: any) {
showNotice('error', err.message || err.toString());
}
@@ -77,7 +77,7 @@ export const ClashCoreViewer = forwardRef<DialogRef>((props, ref) => {
setUpgrading(true);
await upgradeCore();
setUpgrading(false);
showNotice('success', t(`Core Version Updated`), 1000);
showNotice('success', t(`Core Version Updated`));
} catch (err: any) {
setUpgrading(false);
showNotice('error', err.response?.data?.message || err.toString());

View File

@@ -2,7 +2,7 @@ import { forwardRef, useEffect, useImperativeHandle, useState } from "react";
import { useTranslation } from "react-i18next";
import { BaseDialog, DialogRef } from "@/components/base";
import { getNetworkInterfacesInfo } from "@/services/cmds";
import { alpha, Box, Button, Chip, IconButton } from "@mui/material";
import { alpha, Box, Button, IconButton } from "@mui/material";
import { ContentCopyRounded } from "@mui/icons-material";
import { writeText } from "@tauri-apps/plugin-clipboard-manager";
import { showNotice } from "@/services/noticeService";