import { Component, OnInit } from '@angular/core'; import { MenuModel } from './menu.model'; import { logout, MessageService, Serve } from 'pz-unit'; import { NzModalService } from 'ng-zorro-antd'; import { ServeUrl } from 'environments/environment'; export const menuList: MenuModel[] = [ { title: '商品管理', icon: 'appstore', privilege: 1, open: true, selected: false, children: [ { title: '分类管理', routerLink: '/home/commodity-class', icon: 'bars', privilege: 1, children: [], }, { title: '商品列表', routerLink: '/home/commodity-manage', icon: 'bars', privilege: 1, children: [], }, // { // title: '柜子管理', // routerLink: '/cabinet-commodity', // icon: 'bars', // privilege: 1, // children: [], // }, ], }, { title: '订单管理', icon: 'laptop', privilege: 1, open: true, children: [ { title: '订单列表', routerLink: '/home/order-manage', icon: 'customer-service', privilege: 1, children: [], }, ], }, { title: '分享记录', icon: 'solution', privilege: 1, routerLink: '/home/share-log', children: [] }, { title: '拼团管理', icon: 'pie-chart', privilege: 1, routerLink: '/home/group-manage', children: [] }, // { // title: '广告管理', // icon: 'picture', // privilege: 1, // routerLink: '/home/advertising', // children: [] // }, { title: '新人活动', icon: 'gift', privilege: 1, routerLink: '/home/newcomer', children: [] }, // { // title: '留言板', // icon: 'message', // privilege: 1, // routerLink: '/home/message', // children: [] // } ]; @Component({ selector: 'app-my-layout', templateUrl: './my-layout.component.html', styleUrls: ['./my-layout.component.scss'] }) export class MyLayoutComponent implements OnInit { public menuList: MenuModel[] = []; public avator = ''; public testSence: boolean; public constructor(private msg: MessageService, private modal: NzModalService) { // } public ngOnInit() { this.menuList = menuList; this.getRoute(this.msg.routerEvent.urlAfterRedirects); this.msg.routerSubject.subscribe(res => { this.getRoute(res.url); }); this.testSence = !!(Serve(ServeUrl).indexOf('test') > -1); } public getRoute(url: string) { this.menuList.forEach((menu, index) => { if (menu.routerLink && menu.routerLink === `${url}`) { menu.selected = true; } if (menu.children.length) { menu.children.forEach((sub) => { if (sub.routerLink && sub.routerLink === `${url}`) { menu.open = true; sub.selected = true; } }); } }); } public loginOut() { logout(); } public trackByFn(i: number) { return i; } public config() { this.msg.configShow(); } public swagger() { const swaggerUrl = Serve(ServeUrl).replace(/:[0-9]+\/[\w\W]*/, ':8083/'); window.open(`${swaggerUrl}swagger-ui.html`); } }