From 43479516a591e75b0ba16039b3d18edb459cdbb4 Mon Sep 17 00:00:00 2001 From: Jorylee <1747358809@qq.com> Date: Wed, 29 Jan 2025 23:53:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(components):=20=E4=BF=AE=E5=A4=8D=20Popup?= =?UTF-8?q?=20=E7=BB=84=E4=BB=B6=E7=9A=84=E6=8A=A5=E9=94=99=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 引入 lodash 的 once 函数,确保弹窗关闭及卸载逻辑只执行一次 --- src/components/popup.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/popup.tsx b/src/components/popup.tsx index a39999fc..259d8071 100644 --- a/src/components/popup.tsx +++ b/src/components/popup.tsx @@ -2,6 +2,7 @@ import React from "react"; import { createRoot } from "react-dom/client"; import { MouseLocation } from "../core/service/controlService/MouseLocation"; import { cn } from "../utils/cn"; +import once from "lodash/once"; import Box from "./Box"; export namespace Popup { @@ -17,10 +18,13 @@ export namespace Popup { y={MouseLocation.y} onClose={() => { resolve(); - setTimeout(() => { - root.unmount(); - document.body.removeChild(container); - }, 300); + setTimeout( + once(() => { + root.unmount(); + document.body.removeChild(container); + }), + 300, + ); }} > {children}