路由复用优化
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { ChangeDetectorRef } from '@angular/core';
|
||||
import { NavigationEnd, Router } from '@angular/router';
|
||||
|
||||
import { ToastService } from '../../components/toast/toast.service';
|
||||
import { ToastConfig, ToastType } from '../../components/toast/toast-model';
|
||||
@@ -16,7 +17,9 @@ import { AlertMessageHandle } from '../../utils/alert-message-handle';
|
||||
|
||||
import dateFormatter from '../../utils/date-formatter';
|
||||
|
||||
import { filter } from 'rxjs/operators';
|
||||
import * as $ from 'jquery';
|
||||
|
||||
@Component({
|
||||
selector: 'app-main',
|
||||
templateUrl: './main.component.html',
|
||||
@@ -24,6 +27,7 @@ import * as $ from 'jquery';
|
||||
})
|
||||
export class MainComponent implements OnInit {
|
||||
constructor(
|
||||
private router: Router,
|
||||
private basicDataService: BasicDataService,
|
||||
private operateSpinServiceService: OperateSpinServiceService,
|
||||
private httpCilent: HttpClientService,
|
||||
@@ -33,6 +37,30 @@ export class MainComponent implements OnInit {
|
||||
) {
|
||||
this.operateSpinServiceService.showSpin();
|
||||
this.changeDetectorRef.detach();
|
||||
this.router.events.pipe(
|
||||
filter((event => event instanceof NavigationEnd))
|
||||
).subscribe(
|
||||
(event: NavigationEnd) => {
|
||||
console.log(event);
|
||||
if (event.urlAfterRedirects === '/app/main') {
|
||||
this.httpCilent.get('/adminapi/settings/uisettings').subscribe(
|
||||
data => {
|
||||
data.body.forEach(element => {
|
||||
if (element.groupCode === 'userSettingCol') {
|
||||
this.col_lists = JSON.parse(element.settingContent).allCols;
|
||||
this.render_col_lists = JSON.parse(element.settingContent).targetList;
|
||||
} else if (element.groupCode === 'userSettingColor') {
|
||||
this.airline_color = JSON.parse(element.settingContent);
|
||||
} else if (element.groupCode === 'userSettingMsgAlert') {
|
||||
this.airline_message_alert = JSON.parse(element.settingContent).targetList;
|
||||
}
|
||||
});
|
||||
this.changeDetectorRef.detectChanges();
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
public orderHandle = new DynamicFlightOrder();
|
||||
public dataHandle = new FlightsDataHandle();
|
||||
@@ -48,6 +76,7 @@ export class MainComponent implements OnInit {
|
||||
public dynamicAlertArray: Array<any> = [];
|
||||
|
||||
//各项基础数据
|
||||
public flightAgents: Array<any>;
|
||||
public flightTypes: Array<any>;
|
||||
public terminals: Array<any>;
|
||||
public flightStatus: Array<any>;
|
||||
@@ -104,21 +133,6 @@ export class MainComponent implements OnInit {
|
||||
}
|
||||
)
|
||||
|
||||
/* 获取用户设置 */
|
||||
this.httpCilent.get('/adminapi/settings/uisettings').subscribe(
|
||||
data => {
|
||||
data.body.forEach(element => {
|
||||
if (element.groupCode === 'userSettingCol') {
|
||||
this.col_lists = JSON.parse(element.settingContent).allCols;
|
||||
this.render_col_lists = JSON.parse(element.settingContent).targetList;
|
||||
} else if (element.groupCode === 'userSettingColor') {
|
||||
this.airline_color = JSON.parse(element.settingContent);
|
||||
} else if (element.groupCode === 'userSettingMsgAlert') {
|
||||
this.airline_message_alert = JSON.parse(element.settingContent).targetList;
|
||||
}
|
||||
})
|
||||
}
|
||||
)
|
||||
//获取航班动态信息
|
||||
this.httpCilent.get('/msgexchangeapi/all/flights').subscribe(
|
||||
data => {
|
||||
@@ -132,6 +146,7 @@ export class MainComponent implements OnInit {
|
||||
});
|
||||
|
||||
//从基础数据服务中拿出部分基础数据
|
||||
this.flightAgents = this.basicDataService.flightAgents;
|
||||
this.flightTypes = this.basicDataService.flightTypes;
|
||||
this.terminals = this.basicDataService.terminal;
|
||||
this.flightStatus = this.basicDataService.flightStatus;
|
||||
@@ -147,6 +162,9 @@ export class MainComponent implements OnInit {
|
||||
this.combined_data = combined_data;
|
||||
this.doSequence(this.combined_data);
|
||||
} else {
|
||||
this.basicDataService.flightAgents_subject.subscribe(
|
||||
val => this.flightAgents = val
|
||||
)
|
||||
this.basicDataService.flightTypes_subject.subscribe(
|
||||
val => this.flightTypes = val
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user