Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

refactor(router): udpate router errorBoundary

haitaoob431c2fcd3af
diff --git a/ui/src/pages/Users/Personal/index.tsx b/ui/src/pages/Users/Personal/index.tsx
index 1507af6b..8d40afec 100644
--- a/ui/src/pages/Users/Personal/index.tsx
+++ b/ui/src/pages/Users/Personal/index.tsx
@@ -47,7 +47,7 @@ const Personal: FC = () => {
tabName,
);
let pageTitle = '';
- if (userInfo) {
+ if (userInfo && userInfo.info && userInfo.has) {
pageTitle = `${userInfo.info.display_name} (${userInfo.info.username})`;
}
const { count = 0, list = [] } = listData?.[tabName] || {};
diff --git a/ui/src/router/RouteErrorBoundary.tsx b/ui/src/router/RouteErrorBoundary.tsx
new file mode 100644
index 00000000..d70683e3
--- /dev/null
+++ b/ui/src/router/RouteErrorBoundary.tsx
@@ -0,0 +1,8 @@
+import Error50X from '@/pages/50X';
+// import Page404 from '@/pages/404';
+
+const Index = () => {
+ return <Error50X />;
+};
+
+export default Index;
diff --git a/ui/src/router/index.tsx b/ui/src/router/index.tsx
index 20f1b520..2e30ce75 100644
--- a/ui/src/router/index.tsx
+++ b/ui/src/router/index.tsx
@@ -2,9 +2,10 @@ import { Suspense, lazy } from 'react';
import { RouteObject } from 'react-router-dom';
import Layout from '@/pages/Layout';
-import ErrorBoundary from '@/pages/50X';
-import baseRoutes, { RouteNode } from '@/router/routes';
-import RouteGuard from '@/router/RouteGuard';
+
+import baseRoutes, { RouteNode } from './routes';
+import RouteGuard from './RouteGuard';
+import RouteErrorBoundary from './RouteErrorBoundary';
const routes: RouteNode[] = [];
@@ -18,7 +19,7 @@ const routeWrapper = (routeNodes: RouteNode[], root: RouteNode[]) => {
) : (
<Layout />
);
- rn.errorElement = <ErrorBoundary />;
+ rn.errorElement = <RouteErrorBoundary />;
} else {
/**
* cannot use a fully dynamic import statement
@@ -37,6 +38,7 @@ const routeWrapper = (routeNodes: RouteNode[], root: RouteNode[]) => {
)}
</Suspense>
);
+ rn.errorElement = <RouteErrorBoundary />;
}
root.push(rn);
const children = Array.isArray(rn.children) ? rn.children : null;