import React, { Component } from 'react'; import { Button, Result, Space, Collapse, Typography } from 'antd'; import { WarningOutlined, ReloadOutlined, HomeOutlined, BugOutlined, } from '@ant-design/icons'; const { Text, Paragraph } = Typography; const { Panel } = Collapse; class ErrorBoundary extends Component { constructor(props) { super(props); this.state = { hasError: false, error: null, errorInfo: null, }; } static getDerivedStateFromError(error) { return { hasError: true }; } componentDidCatch(error, errorInfo) { this.setState({ error, errorInfo, }); console.error('错误边界捕获到错误:', error, errorInfo); if (this.props.onError) { this.props.onError(error, errorInfo); } } handleReload = () => { window.location.reload(); }; handleGoHome = () => { window.location.href = '/'; }; render() { if (this.state.hasError) { if (this.props.fallback) { return this.props.fallback; } return (