"use client"; import React from "react"; import { IconButton } from "./button"; import ResetIcon from "../icons/reload.svg"; import Locale from "../locales"; import './error.scss'; import { Button} from 'antd'; import { Color } from "antd/es/color-picker"; interface IErrorBoundaryState { hasError: boolean; error: Error | null; info: React.ErrorInfo | null; } export class ErrorBoundary extends React.Component { constructor(props: any) { super(props); this.state = { hasError: false, error: null, info: null }; } componentDidCatch(error: Error, info: React.ErrorInfo) { // Update state with error details this.setState({ hasError: true, error, info }); } clearAndSaveData() { // 直接清除数据,不下载备份 localStorage.clear(); location.reload(); } render() { if (this.state.hasError) { // Render error message return (

哎呀,出了点小问题!

系统遇到了意外状况,别担心,我们的技术团队已经收到通知。您可以尝试刷新页面或清除数据来解决问题。

{/* } text="Clear All Data" onClick={() => { this.clearAndSaveData(); }} bordered /> */}
{/* 注释掉错误信息 */} {/*
            {this.state.error?.toString()}
            {this.state.info?.componentStack}
          
*/}
{/* } text="Clear All Data" onClick={() => { this.clearAndSaveData(); }} bordered /> */}
); } // if no error occurred, render children return this.props.children; } }