Merge pull request #17 from ppchart/main

Fix RouteNode type error
This commit is contained in:
robin 2022-11-02 10:55:14 +08:00 committed by GitHub
commit ffb2b6ddc8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 7 deletions

View File

@ -2,9 +2,10 @@ import React, { Suspense, lazy } from 'react';
import { RouteObject, createBrowserRouter } from 'react-router-dom';
import Layout from '@answer/pages/Layout';
import routeConfig from '@/router/route-config';
import routeConfig, { RouteNode } from '@/router/route-config';
import RouteRules from '@/router/route-rules';
import { RouteNode } from '@/router/types';
const routes: RouteObject[] = [];

View File

@ -1,10 +1,5 @@
import { RouteObject } from 'react-router-dom';
import { RouteNode } from '@/router/types';
export interface RouteNode extends RouteObject {
page: string;
children?: RouteNode[];
rules?: string[];
}
const routeConfig: RouteNode[] = [
{
path: '/',

14
ui/src/router/types.ts Normal file
View File

@ -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;