fix: service viewer ref

This commit is contained in:
GyDi 2022-11-21 23:02:48 +08:00
parent 020bd129fb
commit 781c67b31a
No known key found for this signature in database
GPG Key ID: 9C3AD40F1F99880A

View File

@ -1,4 +1,5 @@
import useSWR from "swr"; import useSWR from "swr";
import { forwardRef, useImperativeHandle, useState } from "react";
import { useLockFn } from "ahooks"; import { useLockFn } from "ahooks";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { Button, Stack, Typography } from "@mui/material"; import { Button, Stack, Typography } from "@mui/material";
@ -8,7 +9,6 @@ import {
uninstallService, uninstallService,
patchVergeConfig, patchVergeConfig,
} from "@/services/cmds"; } from "@/services/cmds";
import { forwardRef, useState } from "react";
import { BaseDialog, DialogRef, Notice } from "@/components/base"; import { BaseDialog, DialogRef, Notice } from "@/components/base";
interface Props { interface Props {
@ -27,6 +27,11 @@ export const ServiceViewer = forwardRef<DialogRef, Props>((props, ref) => {
{ revalidateIfStale: false, shouldRetryOnError: false } { revalidateIfStale: false, shouldRetryOnError: false }
); );
useImperativeHandle(ref, () => ({
open: () => setOpen(true),
close: () => setOpen(false),
}));
const state = status != null ? status : "pending"; const state = status != null ? status : "pending";
const onInstall = useLockFn(async () => { const onInstall = useLockFn(async () => {