feat: init

This commit is contained in:
2025-09-05 15:18:10 +08:00
parent ddbee614e8
commit 85244a451e
126 changed files with 3020 additions and 10278 deletions

View File

@@ -0,0 +1,49 @@
// components/ErrorBoundary/index.tsx
import React, { Component, ReactNode } from "react";
import { Result, Button } from "antd-mobile";
interface Props {
children: ReactNode;
fallback?: ReactNode;
}
interface State {
hasError: boolean;
error?: Error;
}
class ErrorBoundary extends Component<Props, State> {
constructor(props: Props) {
super(props);
this.state = { hasError: false };
}
static getDerivedStateFromError(error: Error): State {
return { hasError: true, error };
}
componentDidCatch(error: Error, errorInfo: any) {
console.error("ErrorBoundary caught an error:", error, errorInfo);
}
render() {
if (this.state.hasError) {
if (this.props.fallback) {
return this.props.fallback;
}
return (
<div style={{ padding: "20px", textAlign: "center" }}>
<Result status="error" title="页面出错了" description="抱歉,页面出现了错误" />
<Button color="primary" onClick={() => window.location.reload()}>
</Button>
</div>
);
}
return this.props.children;
}
}
export default ErrorBoundary;