Files
Aluer/frontend/src/main.jsx
T
2026-05-10 12:59:00 +08:00

44 lines
1.1 KiB
React
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App.jsx";
import "./styles.css";
class RootErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = { error: null };
}
static getDerivedStateFromError(error) {
return { error };
}
componentDidCatch(error, info) {
console.error("Aluer Nebula Console crashed", error, info);
}
render() {
if (this.state.error) {
return (
<div className="fatal-shell">
<div className="fatal-card">
<p className="eyebrow">ALUER UI RECOVERY</p>
<h1>界面加载失败</h1>
<p>前端捕获到了运行时错误,但主程序仍可能正常运行。请刷新页面,或替换为最新构建包。</p>
<pre>{String(this.state.error?.message || this.state.error)}</pre>
</div>
</div>
);
}
return this.props.children;
}
}
ReactDOM.createRoot(document.getElementById("root")).render(
<React.StrictMode>
<RootErrorBoundary>
<App />
</RootErrorBoundary>
</React.StrictMode>
);