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 () => { const onInstall = useLockFn(async () => {
try { try {
await installService(); await installService();
mutateCheck(); await mutateCheck();
setOpen(false); setOpen(false);
setTimeout(() => {
mutateCheck();
}, 2000);
Notice.success(t("Service Installed Successfully")); Notice.success(t("Service Installed Successfully"));
} catch (err: any) { } catch (err: any) {
mutateCheck(); mutateCheck();

View File

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