diff --git a/client/admin/web_app.tsx b/client/admin/web_app.tsx index edc6671..18d8145 100644 --- a/client/admin/web_app.tsx +++ b/client/admin/web_app.tsx @@ -7,7 +7,8 @@ import { useNavigate, useLocation, Navigate, - useParams + useParams, + useRouteError } from 'react-router'; import { Layout, Menu, Button, Table, Space, @@ -478,21 +479,44 @@ const ProtectedRoute = ({ children }: { children: React.ReactNode }) => { }; // 错误页面组件 -const ErrorPage = ({ error }: { error?: Error }) => { +const ErrorPage = () => { const { isDark } = useTheme(); + const error = useRouteError() as any; + const errorMessage = error?.statusText || error?.message || '未知错误'; + return ( -
-

发生错误

-

{error?.message || '抱歉,应用程序遇到了一些问题。'}

- +
+

发生错误

+ + {error.stack} + + ) : null + } + className="mb-4" + /> +
+ + +
+
); };