Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
zgwit committed Jul 14, 2024
1 parent d9bffd7 commit b7de2cb
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 69 deletions.
4 changes: 2 additions & 2 deletions src/app/admin/admin.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<div [nzDropdownMenu]="menuDp" class="user" nz-dropdown nzTrigger="click">
<img alt="logo" class="avatar" src="/assets/manager.png">
manager
管理员
</div>
<nz-dropdown-menu #menuDp="nzDropdownMenu">
<ul nz-menu>
Expand All @@ -19,7 +19,7 @@
<li *ngFor="let item of menuList" [nzIcon]="item['icon']"
[nzOpen]="item.open" [nzTitle]="item['title']" nz-submenu>
<ul>
<li *ngFor="let it of item.children" [routerLink]="it['path']" nz-menu-item
<li *ngFor="let it of item.children" [routerLink]="it.path" [queryParams]="it.query" nz-menu-item
nzMatchRouter>{{ it.title }}
</li>
</ul>
Expand Down
106 changes: 39 additions & 67 deletions src/app/admin/admin.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {Component} from '@angular/core';
import {NzContextMenuService, NzDropDownModule} from 'ng-zorro-antd/dropdown';
import {NzDropDownModule} from 'ng-zorro-antd/dropdown';
import {NzLayoutModule} from "ng-zorro-antd/layout";
import {RouterModule} from "@angular/router";
import {CommonModule} from "@angular/common";
import {SmartRequestService} from "@god-jason/smart";

@Component({
selector: 'app-admin',
Expand All @@ -18,27 +19,31 @@ import {CommonModule} from "@angular/common";
})
export class AdminComponent {
edit!: number;
activeMenu: string = '';
ary = [false, false
, false
, false
, false]
menuList = [{
title: '产品管理',
icon: 'project',

menuSetting: any = {
title: '系统设置',
icon: 'apartment',
open: false,
children: [
{
title: '所有产品',
path: '/admin/product'
},
{
title: '所有设备',
path: '/admin/device'
}
]
children: []
}
, {

menuList: any = [
{
title: '产品管理',
icon: 'project',
open: false,
children: [
{
title: '所有产品',
path: '/admin/product'
},
{
title: '所有设备',
path: '/admin/device'
}
]
},
{
title: '连接管理',
icon: 'appstore',
open: false,
Expand All @@ -60,56 +65,23 @@ export class AdminComponent {
path: '/admin/serial'
},
]
}
// ,
// {
// title: '系统设置',
// icon: 'apartment',
// open: false,
// children: [
// {
// title: '网站',
// path: '/admin/setting/web'
// },
// {
// title: '数据库',
// path: '/admin/setting/database'
// },
// {
// title: '日志',
// path: '/admin/setting/log'
// },
// {
// title: '消息总线',
// path: '/admin/setting/mqtt'
// },
// ]
// }
},
this.menuSetting
]

constructor(
private nzContextMenuService: NzContextMenuService,
) {
for (let index = 0; index < this.menuList.length; index++) {
const item = this.menuList[index];
const {children} = item;
for (let i = 0; i < children.length; i++) {
const it = children[i];
if (it.path === location.pathname) {
item.open = true;
}
}
}
constructor(private rs: SmartRequestService,) {
this.load()
}
// contextMenu($event: MouseEvent, menu: NzDropdownMenuComponent, mes: number): void {
// this.edit = mes
// this.nzContextMenuService.create($event, menu);
// }
// clientFm(num: number) {
// this.ary[num] = false

// }
selectDropdown(): void {
this.ary[this.edit] = true
load() {
this.rs.get('setting/modules').subscribe(res => {
res.data?.forEach((s: any) => {
this.menuSetting.children.push({
name: s.name,
path: "/admin/setting",
query: {module: s.module}
})
})
})
}
}

0 comments on commit b7de2cb

Please sign in to comment.