import { Component, type ErrorInfo, type ReactNode } from "react"; import { AlertCircle } from "lucide-react"; import { Button } from "@/components/ui/button"; interface ErrorBoundaryProps { children: ReactNode; resetKey?: string; onResetHome?: () => void; } interface ErrorBoundaryState { error?: Error; } export class ErrorBoundary extends Component { state: ErrorBoundaryState = {}; static getDerivedStateFromError(error: Error): ErrorBoundaryState { return { error }; } override componentDidUpdate(prevProps: ErrorBoundaryProps): void { if (this.state.error && prevProps.resetKey !== this.props.resetKey) { this.setState({ error: undefined }); } } override componentDidCatch(error: Error, info: ErrorInfo): void { console.error("[LinkShell UI ErrorBoundary]", error, info.componentStack); } override render() { const { error } = this.state; if (!error) return this.props.children; return (

当前视图加载遇到问题

{error.message || "页面渲染发生异常,连接与会话数据未受影响。"}

{this.props.onResetHome && ( )}
); } }