fix: check service

This commit is contained in:
MystiPanda 2024-06-13 12:58:47 +08:00
parent 8342f985e5
commit ad1a057edb
No known key found for this signature in database
2 changed files with 10 additions and 2 deletions

View File

@ -41,8 +41,11 @@ export const ServiceViewer = forwardRef<DialogRef, Props>((props, ref) => {
const onInstall = useLockFn(async () => {
try {
await installService();
mutateCheck();
await mutateCheck();
setOpen(false);
setTimeout(() => {
mutateCheck();
}, 2000);
Notice.success(t("Service Installed Successfully"));
} catch (err: any) {
mutateCheck();

View File

@ -4,6 +4,7 @@ import { checkService } from "@/services/cmds";
import { useVerge } from "@/hooks/use-verge";
import getSystem from "@/utils/get-system";
import useSWR from "swr";
import { useEffect } from "react";
const isWIN = getSystem() === "windows";
@ -17,7 +18,7 @@ export const StackModeSwitch = (props: Props) => {
const { verge } = useVerge();
const { enable_service_mode } = verge ?? {};
// service mode
const { data: serviceStatus } = useSWR(
const { data: serviceStatus, mutate: mutateCheck } = useSWR(
isWIN ? "checkService" : null,
checkService,
{
@ -28,6 +29,10 @@ export const StackModeSwitch = (props: Props) => {
const { t } = useTranslation();
useEffect(() => {
mutateCheck();
}, []);
return (
<Tooltip
title={