fix: remove `auth` field, need `next()` for all routes
This commit is contained in:
parent
4115636118
commit
6bd9994084
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"name": "@syy11cn/config-router",
|
||||
"version": "1.0.1",
|
||||
"version": "1.0.3",
|
||||
"description": "A route rendering and route guarding lib.",
|
||||
"author": {
|
||||
"name": "Yiyang Sun",
|
||||
"email": "syy11cn@outlook.com"
|
||||
|
|
|
@ -18,7 +18,7 @@ const RouterView: FunctionComponent<RouterViewProps> = ({
|
|||
let redirectPath: string = '';
|
||||
let agreeToGo = true;
|
||||
|
||||
// Change state of `redirectPath` and `agreeToGo`
|
||||
// Change state of `redirectPath` and `agreeToGo`.
|
||||
function next(path?: string) {
|
||||
agreeToGo = true;
|
||||
if (path) {
|
||||
|
@ -32,8 +32,6 @@ const RouterView: FunctionComponent<RouterViewProps> = ({
|
|||
return (
|
||||
<Switch>
|
||||
{routes.map((route, index) => {
|
||||
// If auth needed.
|
||||
if (route.auth) {
|
||||
// If `next()` called.
|
||||
if (agreeToGo) {
|
||||
// Need to redirect.
|
||||
|
@ -48,6 +46,7 @@ const RouterView: FunctionComponent<RouterViewProps> = ({
|
|||
render={(props) => (
|
||||
<route.component
|
||||
{...props}
|
||||
// Pass routes of route obj down.
|
||||
routes={route.routes}
|
||||
></route.component>
|
||||
)}
|
||||
|
@ -55,21 +54,6 @@ const RouterView: FunctionComponent<RouterViewProps> = ({
|
|||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// No need for auth.
|
||||
return (
|
||||
<Route
|
||||
key={index}
|
||||
path={route.path}
|
||||
render={(props) => (
|
||||
<route.component
|
||||
{...props}
|
||||
routes={route.routes}
|
||||
></route.component>
|
||||
)}
|
||||
></Route>
|
||||
);
|
||||
}
|
||||
})}
|
||||
</Switch>
|
||||
);
|
||||
|
|
|
@ -3,7 +3,6 @@ import * as React from 'react';
|
|||
interface routeType {
|
||||
path: string;
|
||||
component: React.ComponentType<any>;
|
||||
auth?: boolean;
|
||||
exact?: boolean;
|
||||
routes?: Array<routeType> | undefined;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue