新建需要的文件
打开bz-routing.module.ts文件,设置bzRoutes,为下面使用
import { Injectable, NgModule } from '@angular/core';
import { Resolve, RouterModule, Routes } from '@angular/router';
import { Authority } from '@shared/models/authority.enum';
import { Observable } from 'rxjs';
import { OAuth2Service } from '@core/http/oauth2.service';
import { bzComponent } from './bz.component';
import {ConfirmOnExitGuard} from "@core/guards/confirm-on-exit.guard";
import {UserProfileResolver, UserTwoFAProvidersResolver} from "@home/pages/security/security-routing.module";
@Injectable()
export class OAuth2LoginProcessingUrlResolver implements Resolve<string> {
constructor(private oauth2Service: OAuth2Service) {
}
resolve(): Observable<string> {
return this.oauth2Service.getLoginProcessingUrl();
}
}
export const bzRoutes: Routes = [
{
path: 'bz',
component: bzComponent,
canDeactivate: [ConfirmOnExitGuard],
data: {
auth: [Authority.SYS_ADMIN, Authority.TENANT_ADMIN, Authority.CUSTOMER_USER],
title: '子类',
breadcrumb: {
label: '子类',
icon: 'lock'
}
},
resolve: {
user: UserProfileResolver,
providers: UserTwoFAProvidersResolver
}
}
];
const routes: Routes = [//这个和单独显示菜单有关系,和子类显示无关
// {
// path: '/npages1/bz',
// component: bzComponent,
// data: {
// auth: [Authority.TENANT_ADMIN, Authority.CUSTOMER_USER],
// title: 'npages.npages',
// breadcrumb: {
// label: 'npages.npages',
// icon: 'mdi:alert-outline'
// },
// isPage: true,
// alarmsMode: AlarmsMode.ALL
// }
// }
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
providers: []
})
export class bzRoutingModule { }
打开bz1-routing.module.ts文件,设置bz1Routes,为下面使用
import { Injectable, NgModule } from '@angular/core';
import { Resolve, RouterModule, Routes } from '@angular/router';
import { Authority } from '@shared/models/authority.enum';
import { Observable } from 'rxjs';
import { OAuth2Service } from '@core/http/oauth2.service';
import { AlarmsMode } from '@shared/models/alarm.models';
import {bz1Component} from "@home/pages/npages1/bz1/bz1.component";
import {ConfirmOnExitGuard} from "@core/guards/confirm-on-exit.guard";
import {UserProfileResolver, UserTwoFAProvidersResolver} from "@home/pages/security/security-routing.module";
@Injectable()
export class OAuth2LoginProcessingUrlResolver implements Resolve<string> {
constructor(private oauth2Service: OAuth2Service) {
}
resolve(): Observable<string> {
return this.oauth2Service.getLoginProcessingUrl();
}
}
export const bz1Routes: Routes = [
{
path: 'bz1',
component: bz1Component,
canDeactivate: [ConfirmOnExitGuard],
data: {
auth: [Authority.SYS_ADMIN, Authority.TENANT_ADMIN, Authority.CUSTOMER_USER],
title: '子类1',
breadcrumb: {
label: '子类1',
icon: 'lock'
}
},
resolve: {
user: UserProfileResolver,
providers: UserTwoFAProvidersResolver
}
}
];
const routes: Routes = [//这个和单独显示菜单有关系,和子类显示无关
// {
// path: '/npages1/bz1',
// component: bz1Component,
// data: {
// auth: [Authority.TENANT_ADMIN, Authority.CUSTOMER_USER],
// title: 'npages.npages',
// breadcrumb: {
// label: 'npages.npages',
// icon: 'mdi:alert-outline'
// },
// isPage: true,
// alarmsMode: AlarmsMode.ALL
// }
// }
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
providers: []
})
export class bz1RoutingModule { }
打开npages-routing.module.ts文件,调用刚刚生成的bzRoutes以及bz1Routes。
import { Injectable, NgModule } from '@angular/core';
import { Resolve, RouterModule, Routes } from '@angular/router';
import { Authority } from '@shared/models/authority.enum';
import { Observable } from 'rxjs';
import { OAuth2Service } from '@core/http/oauth2.service';
import {bzRoutes} from "./bz/bz-routing.module";
import {bz1Routes} from "./bz1/bz1-routing.module";
@Injectable()
export class OAuth2LoginProcessingUrlResolver implements Resolve<string> {
constructor(private oauth2Service: OAuth2Service) {
}
resolve(): Observable<string> {
return this.oauth2Service.getLoginProcessingUrl();
}
}
const routes: Routes = [
{
path: 'npages1',
data: {
auth: [Authority.TENANT_ADMIN, Authority.CUSTOMER_USER],
breadcrumb: {
skip: true
}
},
children: [
{
path: '',
children: [],
data: {
auth: [Authority.TENANT_ADMIN, Authority.CUSTOMER_USER],
redirectTo: ''
}
},
...bzRoutes,
...bz1Routes
]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
providers: []
})
export class npages1RoutingModule { }
打开npages-module.ts文件,配置module类
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { SharedModule } from '@shared/shared.module';
import { bzComponent } from './bz/bz.component';
import { bz1Component } from './bz1/bz1.component';
import { HomeDialogsModule } from '../../dialogs/home-dialogs.module';
import { HomeComponentsModule } from '@modules/home/components/home-components.module';
import { npages1RoutingModule } from '@home/pages/npages1/npages1-routing.module';
@NgModule({
declarations: [bzComponent,bz1Component],
imports: [
CommonModule,
SharedModule,
HomeComponentsModule,
HomeDialogsModule,
npages1RoutingModule
]
})
export class Npages1Module { }
打开home-pages.module.ts文件,导入module类
import {Npages1Module} from '@home/pages/npages1/npages1.module'
最后在menu.service.ts中写入引用类
{
id: 'ceshi1',
name: '菜单子类',
type: 'toggle',
path: '/npages1',
icon: 'category',
pages: [
{
id: 'testbz',
name: '子类',
type: 'link',
path: '/npages1/bz',
icon: 'devices_other'
},
{
id: 'testbz1',
name: '子类1',
type: 'link',
path: '/npages1/bz1',
icon: 'domain'
}
]
},