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.

Fix RouteNode type error

ppchart4fc3caebe679
diff --git a/ui/src/router/index.tsx b/ui/src/router/index.tsx
index b9dbb2de..aa279cf3 100644
--- a/ui/src/router/index.tsx
+++ b/ui/src/router/index.tsx
@@ -1,8 +1,9 @@
import React, { Suspense, lazy } from 'react';
import { RouteObject, createBrowserRouter } from 'react-router-dom';
-import routeConfig, { RouteNode } from '@/router/route-config';
+import routeConfig from '@/router/route-config';
import RouteRules from '@/router/route-rules';
+import { RouteNode } from './types';
const routes: RouteObject[] = [];
diff --git a/ui/src/router/route-config.ts b/ui/src/router/route-config.ts
index 6267482e..c347922e 100644
--- a/ui/src/router/route-config.ts
+++ b/ui/src/router/route-config.ts
@@ -1,10 +1,5 @@
-import { RouteObject } from 'react-router-dom';
+import { RouteNode } from './types';
-export interface RouteNode extends RouteObject {
- page: string;
- children?: RouteNode[];
- rules?: string[];
-}
const routeConfig: RouteNode[] = [
{
path: '/',
diff --git a/ui/src/router/types.ts b/ui/src/router/types.ts
new file mode 100644
index 00000000..f0d13c87
--- /dev/null
+++ b/ui/src/router/types.ts
@@ -0,0 +1,14 @@
+import { IndexRouteObject, NonIndexRouteObject } from 'react-router-dom';
+
+type CustomRouteObject = {
+ page: string;
+ rules?: string[];
+};
+
+type IndexRouteNode = IndexRouteObject & CustomRouteObject;
+
+interface NonIndexRouteNode extends NonIndexRouteObject, CustomRouteObject {
+ children?: (IndexRouteNode | NonIndexRouteNode)[];
+}
+
+export type RouteNode = IndexRouteNode | NonIndexRouteNode;