Parcourir la source

fix: service viewer ref

GyDi il y a 2 ans
Parent
commit
781c67b31a
1 fichiers modifiés avec 6 ajouts et 1 suppressions
  1. 6 1
      src/components/setting/mods/service-viewer.tsx

+ 6 - 1
src/components/setting/mods/service-viewer.tsx

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