我已经成功生成了一个单片jhipster 4.13应用程序,并将其修改为使用登录页面启动。
以下是我app.route.ts的内容:
export const APP_ROUTE: Routes = [
{
path: '',
component: HomeLayoutComponent,
data: {
authorities: ['ROLE_USER'],
pageTitle: 'home.title'
},
canActivate: [ UserRouteAccessService ],
children: [
{ path: '', component: NavbarComponent, outlet: 'navbar' },
{ path: 'home', component: HomeComponent },
]
},
{
path: '',
component: LoginLayoutComponent,
children: [
{ path: 'login', component: LoginComponent },
{ path: 'register', component: RegisterComponent },
{ path: 'reset', component: RegisterComponent },
]
},
{ path: '**', redirectTo: 'home', pathMatch: 'full' },
];
app-routing.module.ts文件的内容:
const LAYOUT_ROUTES = APP_ROUTE;
[
APP_ROUTE,
navbarRoute,
...errorRoute
];
@NgModule({
imports: [
RouterModule.forRoot(LAYOUT_ROUTES, { useHash: true })
],
exports: [
RouterModule
]
})
export class AppRoutingModule {}
以下是新的布局模板: JHI-主:
<router-outlet></router-outlet>
JHI-登录布局:
<jhi-page-ribbon></jhi-page-ribbon>
<router-outlet></router-outlet>
<jhi-footer></jhi-footer>
JHI家庭布局:
<jhi-page-ribbon></jhi-page-ribbon>
<div>
<router-outlet name="navbar"></router-outlet>
</div>
<div class="container-fluid">
<div class="card jh-card">
<router-outlet></router-outlet>
<router-outlet name="popup"></router-outlet>
</div>
<jhi-footer></jhi-footer>
</div>
经过这些修改后,我的应用程序在登录页面上按预期启动,经过身份验证后我可以通过导航栏到达我的主页。我也可以退出 成功,但我不再能够启动这些页面,如:
"jhi-metrics", "jhi-health"; "jhi-configuration"; "audits" or "logs".
有什么想法吗?
考虑到@sue的建议添加{enableTracing:true}
Router Event: NavigationStart
NavigationStart(id: 7, url: '/home/(jhi-metrics)')
Router Event: RoutesRecognized
RoutesRecognized(id: 7, url: '/home/(jhi-metrics)', urlAfterRedirects: '/home', state: Route(url:'', path:'') { Route(url:'', path:'') { Route(url:'home', path:'home'), Route(url:'', path:'') } } )
Router Event: GuardsCheckStart
GuardsCheckStart(id: 7, url: '/home/(jhi-metrics)', urlAfterRedirects: '/home', state: Route(url:'', path:'') { Route(url:'', path:'') { Route(url:'home', path:'home'), Route(url:'', path:'') } } )
Router Event: GuardsCheckEnd
GuardsCheckEnd(id: 7, url: '/home/(jhi-metrics)', urlAfterRedirects: '/home', state: Route(url:'', path:'') { Route(url:'', path:'') { Route(url:'home', path:'home'), Route(url:'', path:'') } } , shouldActivate: true)
Router Event: ActivationEnd
ActivationEnd(path: 'home')
Router Event: ActivationEnd
ActivationEnd(path: '')
Router Event: ChildActivationEnd
ChildActivationEnd(path: '')
Router Event: ActivationEnd
ActivationEnd(path: '')
Router Event: ChildActivationEnd
ChildActivationEnd(path: '')
Router Event: NavigationEnd
NavigationEnd(id: 7, url: '/home/(jhi-metrics)', urlAfterRedirects: '/home')
答案 0 :(得分:1)
https://angular.io/guide/router也许可以帮助你。
打开浏览器调试模式,并检查路由
的路径
@NgModule({
imports: [
RouterModule.forRoot(
appRoutes,
{ enableTracing: true } // <-- debugging purposes only
)
// other imports here
],
...
})
&#13;