Commit 5d60f0c9 authored by Chunchi Che's avatar Chunchi Che

optimize NeosModal

parent 2e26ecf6
Pipeline #25437 passed with stages
in 14 minutes and 46 seconds
...@@ -3,6 +3,8 @@ import { Modal, type ModalProps } from "antd"; ...@@ -3,6 +3,8 @@ import { Modal, type ModalProps } from "antd";
import classNames from "classnames"; import classNames from "classnames";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { sleep } from "@/infra";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
export const NeosModal: React.FC<ModalProps> = (props) => { export const NeosModal: React.FC<ModalProps> = (props) => {
...@@ -11,9 +13,15 @@ export const NeosModal: React.FC<ModalProps> = (props) => { ...@@ -11,9 +13,15 @@ export const NeosModal: React.FC<ModalProps> = (props) => {
// 为了修antd的bug,先让isOpen发生变化,同时设置visibility为`hidden`,再让它变回来 // 为了修antd的bug,先让isOpen发生变化,同时设置visibility为`hidden`,再让它变回来
const [realOpen, setRealOpen] = useState(true); const [realOpen, setRealOpen] = useState(true);
const [hidden, setHidden] = useState(true); const [hidden, setHidden] = useState(true);
useEffect(() => {
const close = async () => {
setRealOpen(false); setRealOpen(false);
await sleep(1000);
setHidden(false); setHidden(false);
};
useEffect(() => {
close();
}, []); }, []);
useEffect(() => setRealOpen(!!props.open), [props.open]); useEffect(() => setRealOpen(!!props.open), [props.open]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment