|
@@ -32,7 +32,10 @@ class NavigationGuards extends Component<NavigationGuardsProps, any> {
|
|
|
changDocumentTitle = (path: string) => {
|
|
|
|
|
|
const pathTitle = frameStore.routeNameMapping.get(path) as string
|
|
|
- if (escape(pathTitle).indexOf("%u") < 0) {
|
|
|
+ if (!pathTitle) {
|
|
|
+ document.title = consts.NAME
|
|
|
+ }
|
|
|
+ if (pathTitle && escape(pathTitle).indexOf("%u") < 0) {
|
|
|
// 没有中文,需要拿到父级路由的title,依次循环
|
|
|
this.changDocumentTitle(path.substring(0, path.lastIndexOf("/")))
|
|
|
} else {
|
|
@@ -87,7 +90,7 @@ class NavigationGuards extends Component<NavigationGuardsProps, any> {
|
|
|
//如果访问子菜单,则跳转到子菜单的默认路由
|
|
|
if (targetPath && frameStore.defaultRouteMapping.has(targetPath)) {
|
|
|
const targetDefaultRoute: string = frameStore.defaultRouteMapping.get(targetPath) as string
|
|
|
- return <Redirect to={targetDefaultRoute}></Redirect>
|
|
|
+ return <Redirect to={targetDefaultRoute} />
|
|
|
}
|
|
|
|
|
|
const findRes = targetPath && NavigationGuards.findTargetRoute(parentPath, targetPath, routeConfig)
|
|
@@ -108,15 +111,15 @@ class NavigationGuards extends Component<NavigationGuardsProps, any> {
|
|
|
}
|
|
|
|
|
|
if (targetRoute.redirect && !targetRoute.component) {
|
|
|
- return <Redirect to={targetRoute.redirect}></Redirect>
|
|
|
+ return <Redirect to={targetRoute.redirect} />
|
|
|
}
|
|
|
|
|
|
|
|
|
//以下部分可提出去作为用户自定义部分
|
|
|
if (isLogin) {
|
|
|
- return <LoginHandler ErrorPage={ErrorPage} targetRoute={targetRoute}></LoginHandler>
|
|
|
+ return <LoginHandler ErrorPage={ErrorPage} targetRoute={targetRoute} />
|
|
|
} else {
|
|
|
- return <NotLoginHandler targetRoute={targetRoute}></NotLoginHandler>
|
|
|
+ return <NotLoginHandler targetRoute={targetRoute} />
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -128,23 +131,23 @@ function LoginHandler(props: { targetRoute: RouteModel, ErrorPage: any }): any {
|
|
|
const noCache = targetRoute.meta?.noCache ? targetRoute.meta.noCache : false
|
|
|
|
|
|
if (path === '/login') {
|
|
|
- return <Redirect to="/console/dashboard"></Redirect>
|
|
|
+ return <Redirect to="/console/dashboard" />
|
|
|
} else if (!auth || NavigationGuards.permissionAuthentication(auth, userStore.role)) {
|
|
|
return (
|
|
|
<Route path={path} render={
|
|
|
props => (
|
|
|
noCache ?
|
|
|
- <targetRoute.component {...props} routeConfig={targetRoute.childRoutes}></targetRoute.component> :
|
|
|
+ <targetRoute.component {...props} routeConfig={targetRoute.childRoutes} /> :
|
|
|
(
|
|
|
<KeepAlive>
|
|
|
- <targetRoute.component {...props} routeConfig={targetRoute.childRoutes}></targetRoute.component>
|
|
|
+ <targetRoute.component {...props} routeConfig={targetRoute.childRoutes} />
|
|
|
</KeepAlive>
|
|
|
)
|
|
|
)
|
|
|
- }></Route>
|
|
|
+ } />
|
|
|
)
|
|
|
} else {
|
|
|
- return <ErrorPage message="您无权访问此页"></ErrorPage>
|
|
|
+ return <ErrorPage message="您无权访问此页" />
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -154,13 +157,13 @@ function NotLoginHandler(props: { targetRoute: RouteModel }): any {
|
|
|
const { path, auth } = targetRoute
|
|
|
|
|
|
if (auth && auth.length > 0) {
|
|
|
- return <Redirect to="/login"></Redirect>
|
|
|
+ return <Redirect to="/login" />
|
|
|
} else {
|
|
|
return <Route path={path} render={
|
|
|
props => (
|
|
|
- <targetRoute.component {...props} routeConfig={targetRoute.childRoutes}></targetRoute.component>
|
|
|
+ <targetRoute.component {...props} routeConfig={targetRoute.childRoutes} />
|
|
|
)
|
|
|
- }></Route>
|
|
|
+ } />
|
|
|
}
|
|
|
}
|
|
|
|