|
@@ -1,5 +1,5 @@
|
1
|
1
|
import { Component, OnInit } from "@angular/core";
|
2
|
|
-import { Router } from "@angular/router";
|
|
2
|
+import { Router, NavigationStart } from "@angular/router";
|
3
|
3
|
import { FormBuilder, Validators, FormGroup } from "@angular/forms";
|
4
|
4
|
import { NzMessageService } from "ng-zorro-antd/message";
|
5
|
5
|
import { MainService } from "../../services/main.service";
|
|
@@ -19,6 +19,7 @@ export class LoginComponent implements OnInit {
|
19
|
19
|
validateForm: FormGroup;
|
20
|
20
|
loading: boolean = false; // 加载状态
|
21
|
21
|
isSingleSignOn: boolean = false; // 是否单点登录
|
|
22
|
+ rooterChange
|
22
|
23
|
constructor(
|
23
|
24
|
private router: Router,
|
24
|
25
|
private fb: FormBuilder,
|
|
@@ -28,12 +29,29 @@ export class LoginComponent implements OnInit {
|
28
|
29
|
private titleService: Title,
|
29
|
30
|
private markingService: MarkingService,
|
30
|
31
|
) {}
|
|
32
|
+ ngOnDestroy() {
|
|
33
|
+ if (this.rooterChange) {
|
|
34
|
+ this.rooterChange.unsubscribe();
|
|
35
|
+ }
|
|
36
|
+ }
|
31
|
37
|
ngOnInit() {
|
32
|
38
|
this.http = http;
|
33
|
39
|
this.isSingleSignOn = location.href.includes("?");
|
34
|
40
|
if (this.isSingleSignOn) {
|
35
|
41
|
this.singleSignOn();
|
36
|
42
|
} else {
|
|
43
|
+ this.rooterChange = this.router.events.subscribe(event => {
|
|
44
|
+ if(event instanceof NavigationStart) {
|
|
45
|
+ console.log(event, 'NavigationStart')
|
|
46
|
+ let reg = /^\/login\/?(\d*)$/;
|
|
47
|
+ let isHosIdLogin = reg.test(event.url);
|
|
48
|
+ console.log(isHosIdLogin)
|
|
49
|
+ if(isHosIdLogin){
|
|
50
|
+ // 登录页
|
|
51
|
+ location.reload(true);
|
|
52
|
+ }
|
|
53
|
+ }
|
|
54
|
+ })
|
37
|
55
|
this.initForm();
|
38
|
56
|
}
|
39
|
57
|
}
|