import { useState, useEffect } from 'react'; import { Typography, Space, Divider, Badge, Button } from 'antd'; import { GithubOutlined, CopyrightOutlined, HeartFilled, ClockCircleOutlined, GiftOutlined } from '@ant-design/icons'; import { VERSION_INFO, getVersionString } from '../config/version'; import { checkLatestVersion } from '../services/versionService'; const { Text, Link } = Typography; export default function AppFooter() { const isMobile = window.innerWidth <= 768; const [hasUpdate, setHasUpdate] = useState(false); const [latestVersion, setLatestVersion] = useState(''); const [releaseUrl, setReleaseUrl] = useState(''); useEffect(() => { // 检查版本更新(每次都重新检查) const checkVersion = async () => { try { const result = await checkLatestVersion(); setHasUpdate(result.hasUpdate); setLatestVersion(result.latestVersion); setReleaseUrl(result.releaseUrl); } catch (error) { // 静默失败 } }; // 延迟3秒后检查,避免影响首次加载 const timer = setTimeout(checkVersion, 3000); return () => clearTimeout(timer); }, []); // 点击版本号查看更新 const handleVersionClick = () => { if (hasUpdate && releaseUrl) { window.open(releaseUrl, '_blank'); } }; return (
{isMobile ? ( // 移动端:紧凑单行布局
{VERSION_INFO.projectName} {getVersionString()} {VERSION_INFO.buildTime}
) : ( // PC端:完整布局 } style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }} > {/* 版本信息 */} { if (hasUpdate) { e.currentTarget.style.transform = 'scale(1.05)'; } }} onMouseLeave={(e) => { if (hasUpdate) { e.currentTarget.style.transform = 'scale(1)'; } }} title={hasUpdate ? `发现新版本 v${latestVersion},点击查看` : '当前版本'} > {VERSION_INFO.projectName} {getVersionString()} {/* GitHub 链接 */} GitHub {/* LinuxDO 社区 */} LinuxDO 社区 {/* 赞助按钮 */} {/* 许可证 */} {VERSION_INFO.license} {/* 更新时间 */} {VERSION_INFO.buildTime} {/* 致谢信息 */} Made with by {VERSION_INFO.author} )}
); }