routes-routing.module.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { NgModule } from '@angular/core';
  2. import { RouterModule, Routes } from '@angular/router';
  3. import { environment } from '@env/environment';
  4. // layout
  5. import { DetectAuthGuard } from '../core/guard/detect-auth-guard';
  6. import { LayoutBasicComponent } from '../layout/basic/basic.component';
  7. import { LayoutPassportComponent } from '../layout/passport/passport.component';
  8. // dashboard pages
  9. import { DashboardComponent } from './dashboard/dashboard.component';
  10. // single pages
  11. import { UserLockComponent } from './passport/lock/lock.component';
  12. // passport pages
  13. import { UserLoginComponent } from './passport/login/login.component';
  14. const routes: Routes = [
  15. {
  16. path: '',
  17. component: LayoutBasicComponent,
  18. // 路由守卫 在路由之前判断是否有认证或者权限进入此路由
  19. canActivate: [DetectAuthGuard],
  20. children: [
  21. // todo 根据路由自动生成面包屑
  22. { path: '', redirectTo: 'dashboard', pathMatch: 'full' },
  23. { path: 'dashboard', component: DashboardComponent, data: { title: '仪表盘' } },
  24. { path: 'exception', loadChildren: () => import('./exception/exception.module').then(m => m.ExceptionModule) },
  25. { path: 'monitors', loadChildren: () => import('./monitor/monitor.module').then(m => m.MonitorModule) },
  26. { path: 'alert', loadChildren: () => import('./alert/alert.module').then(m => m.AlertModule) }
  27. ]
  28. },
  29. // 空白布局
  30. // {
  31. // path: 'blank',
  32. // component: LayoutBlankComponent,
  33. // children: [
  34. // ]
  35. // },
  36. // passport
  37. {
  38. path: 'passport',
  39. component: LayoutPassportComponent,
  40. children: [
  41. { path: 'login', component: UserLoginComponent, data: { title: '登录' } },
  42. { path: 'lock', component: UserLockComponent, data: { title: '锁屏' } }
  43. ]
  44. },
  45. { path: '**', redirectTo: 'exception/404' }
  46. ];
  47. @NgModule({
  48. imports: [
  49. RouterModule.forRoot(routes, {
  50. useHash: environment.useHash,
  51. // NOTICE: If you use `reuse-tab` component and turn on keepingScroll you can set to `disabled`
  52. // Pls refer to https://ng-alain.com/components/reuse-tab
  53. scrollPositionRestoration: 'top'
  54. })
  55. ],
  56. exports: [RouterModule]
  57. })
  58. export class RouteRoutingModule {}