胡锐 8 months ago
commit 8ad414aa26
  1. 12
      src/app/pages/body/tab/tab.component.ts

@ -3,7 +3,6 @@ import {NgForOf} from "@angular/common";
import {NzTabComponent, NzTabSetComponent} from "ng-zorro-antd/tabs"; import {NzTabComponent, NzTabSetComponent} from "ng-zorro-antd/tabs";
import {ActivationEnd, Router, RouterOutlet} from "@angular/router"; import {ActivationEnd, Router, RouterOutlet} from "@angular/router";
import {filter} from "rxjs"; import {filter} from "rxjs";
import {MenuService} from "../../../servies/menu/menu.service";
import {NzCardComponent} from "ng-zorro-antd/card"; import {NzCardComponent} from "ng-zorro-antd/card";
@Component({ @Component({
@ -30,22 +29,21 @@ export class TabComponent {
// 监听路由事件,只订阅 ActivationEnd 事件 // 监听路由事件,只订阅 ActivationEnd 事件
this.router.events.pipe(filter(e => e instanceof ActivationEnd)) this.router.events.pipe(filter(e => e instanceof ActivationEnd))
.subscribe((e) => { .subscribe((e) => {
// 这里不强转VS Code编译通不过,有没有大佬有解决方法 // 这里不强转VS Code编译通不过,有没有大佬有解决方法
const thisEvt = <ActivationEnd>e; const thisEvt = <ActivationEnd>e;
if (thisEvt.snapshot.routeConfig?.loadChildren) { if (thisEvt.snapshot.routeConfig?.loadChildren) {
// 当前激活的路由 // 当前激活的路由
// const activatedRoutePath = thisEvt.snapshot.routeConfig?.path; // const activatedRoutePath = thisEvt.snapshot.routeConfig?.path;
const activatedRoutePath = this.router.url; const activatedRoutePath = this.router.url;
// console.log(activatedRoutePath); // console.log(activatedRoutePath);
/* if (activatedRoutePath == '/admin/index') { /* if (activatedRoutePath == '/admin/index') {
return; return;
}*/ }*/
const routeData = thisEvt.snapshot.queryParams; const routeData = thisEvt.snapshot.queryParams;
let menuTitle = '新标签页'; let menuTitle = '新标签页';
if(routeData) { if(routeData) {
menuTitle = routeData['title']; menuTitle = routeData['title'];
}
// 该路由是否已激活,激活过则直接打开 // 该路由是否已激活,激活过则直接打开
let isExist = false; let isExist = false;

Loading…
Cancel
Save