routes-routing.module.ts 2.7 KB

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