From a19a091a9a22eb1c295aa999f58e2c6db75b1450 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 24 Sep 2020 08:00:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=91=E5=90=AC=E6=A0=87=E7=AD=BE=E5=88=87?= =?UTF-8?q?=E6=8D=A2=EF=BC=8C=E5=8A=A0=E8=BD=BD=E7=9B=B8=E5=85=B3=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=EF=BC=88=E6=9C=AA=E5=85=B7=E4=BD=93=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=EF=BC=89=20=E7=9B=91=E5=90=AC=E8=B7=AF=E7=94=B1=EF=BC=8C?= =?UTF-8?q?=E6=97=A0=E5=AF=B9=E5=BA=94=E6=A0=87=E7=AD=BE=EF=BC=8C=E5=88=99?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E6=96=B0=E5=BB=BA=E6=A0=87=E7=AD=BE=EF=BC=88?= =?UTF-8?q?=E6=9C=AA=E5=AE=9E=E7=8E=B0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- portal/src/app/main/main.component.html | 2 +- portal/src/app/main/main.component.ts | 50 +++++++++++++++++++------ 2 files changed, 39 insertions(+), 13 deletions(-) diff --git a/portal/src/app/main/main.component.html b/portal/src/app/main/main.component.html index 1b6d8de..80212a8 100644 --- a/portal/src/app/main/main.component.html +++ b/portal/src/app/main/main.component.html @@ -32,7 +32,7 @@
- + Default Default. diff --git a/portal/src/app/main/main.component.ts b/portal/src/app/main/main.component.ts index 3e40aa6..a9396b0 100644 --- a/portal/src/app/main/main.component.ts +++ b/portal/src/app/main/main.component.ts @@ -58,23 +58,49 @@ export class MainComponent implements OnInit { @ViewChild("container", {read: ViewContainerRef}) container: ViewContainerRef; constructor(private mqtt: MqttService, private router: Router, private resolver: ComponentFactoryResolver) { - router.events.subscribe((e:any) => { - console.log('router event', e) - if (this.container && this.container.createComponent - && e.snapshot && e.snapshot.component && e.snapshot.children.length==0) { - - const factory = resolver.resolveComponentFactory(e.snapshot.component); - this.container.clear(); - const ref = this.container.createComponent(factory); - //TODO 第一次,container还未准备好 - //TODO 添加路由参数 - //TODO call ref.destroy() in ngOnDestroy - } + router.events.subscribe((e: any) => { + //console.log('router event', e) + // if (this.container && this.container.createComponent + // && e.snapshot && e.snapshot.component && e.snapshot.children.length == 0) { + // + // const factory = resolver.resolveComponentFactory(e.snapshot.component); + // this.container.clear(); + // const ref = this.container.createComponent(factory); + // //TODO 第一次,container还未准备好 + // //TODO 添加路由参数 + // //TODO call ref.destroy() in ngOnDestroy + // + // + // } }); //TODO unsubscribe } + tabs = []; + + onTabsChange(e): void { + //TODO 实现标签页 + // 1、打开对应标签,如果未加载组件,则解析路由,导入组件,已加载则忽略 + // 2、路由切换,没有自动打开对应标签,可能情况: + // a、标签未创建或已经关闭,此时需要自动创建新标签,打开页面 + // b、无效路由 + // + + //e.index + + // this.router.routerState.snapshot.root.firstChild.firstChild.firstChild... + let route: any = this.router.routerState.snapshot.root; + while (route.firstChild) { + route = route.firstChild; + } + const factory = this.resolver.resolveComponentFactory(route.component); + + this.container.clear(); + const ref = this.container.createComponent(factory); + + } + ngOnInit(): void { this.mqtt.subscribe('/+/+/recv').subscribe(packet => { console.log('packet', packet); -- GitLab