Files
aphrodite/src/components/Stars/StarModal/index.tsx
2025-03-22 00:01:11 +08:00

36 lines
974 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React, { useEffect, useState, ReactNode } from 'react';
import Modal, { ModalProps } from 'antd/lib/modal';
import { StarProps } from '../interface';
/**
* 星级模态框组件基于Antd Modal的增强组件
* 提供国际化和组件生命周期管理功能
*/
const StarModal: React.FC<ModalProps & StarProps & { children: ReactNode }> = (props) => {
const { open, destroyOnClose, children, format: formate, ...rest } = props;
const [exist, setExist] = useState<boolean | undefined>(open);
useEffect(() => {
if (open) setExist(open);
}, [open]);
const elements = exist ? (
<Modal
destroyOnClose={destroyOnClose}
open={open}
afterClose={() => setExist(false)}
okText={formate ? formate({ id: 'confirm' }) : '确定'}
cancelText={formate ? formate({ id: 'cancel' }) : '取消'}
{...rest}
>
{children}
</Modal>
) : (
<div />
);
return elements;
};
export default StarModal;