import React, { useEffect, useState } from 'react'; import { CloseOutlined, RocketOutlined } from '@ant-design/icons'; import ReactMarkdown from 'react-markdown'; import rehypeRaw from 'rehype-raw'; import { shouldShowUpdate, isUpdateNotificationDisabled } from './version'; import './style.less'; interface UpdateNotificationProps { version: string; // 版本号,用于控制是否显示 } const UpdateNotification: React.FC = ({ version }) => { const [visible, setVisible] = useState(false); const [content, setContent] = useState(''); const [isAnimating, setIsAnimating] = useState(false); useEffect(() => { // 检查是否被禁用 if (isUpdateNotificationDisabled()) { return; } // 检查是否已经看过这个版本的更新 const lastViewedVersion = localStorage.getItem('lastViewedUpdateVersion'); if (shouldShowUpdate(lastViewedVersion)) { // 立即保存版本号,防止退出登录或刷新后重复显示 localStorage.setItem('lastViewedUpdateVersion', version); // 加载更新内容 import('./update.md?raw') .then((module) => { setContent(module.default); setTimeout(() => { setVisible(true); setIsAnimating(true); }, 800); }) .catch(() => { console.error('Failed to load update content'); }); } }, [version]); const handleClose = () => { setIsAnimating(false); setTimeout(() => { setVisible(false); }, 300); }; if (!visible) return null; return ( <> {/* 遮罩层 */}
{/* 弹窗 */}
版本更新公告

, h2: (props) =>

, h3: (props) =>

, p: (props) =>

, ul: (props) =>

    , li: (props) =>
  • , strong: (props) => , code: (props) => ( ), }} > {content}

); }; export default UpdateNotification;