seimin 1 year ago
parent
commit
0c1f2232ca
3 changed files with 22 additions and 4 deletions
  1. 1 1
      proxy.conf.json
  2. 2 2
      src/app/app.component.ts
  3. 19 1
      src/app/views/login/login.component.ts

+ 1 - 1
proxy.conf.json

@@ -1,6 +1,6 @@
1
 {
1
 {
2
   "/service": {
2
   "/service": {
3
-    "target": "http://192.168.3.108",
3
+    "target": "http://192.168.4.163",
4
     "logLevel": "debug",
4
     "logLevel": "debug",
5
     "changeOrigin": true,
5
     "changeOrigin": true,
6
     "pathRewrite": {
6
     "pathRewrite": {

+ 2 - 2
src/app/app.component.ts

@@ -16,8 +16,8 @@ export class AppComponent {
16
     if(isHosIdLogin){
16
     if(isHosIdLogin){
17
       // 登录页
17
       // 登录页
18
       hosId = location.hash.replace(reg, '$1');
18
       hosId = location.hash.replace(reg, '$1');
19
-    }else if(location.hash == '#/main/sysConfig' || location.hash == ''){
20
-      // 系统配置页
19
+    }else if(location.hash == '#/main/sysConfig' || location.hash == '' || location.href.includes("?")){
20
+      // 系统配置页||重定向前||单点登录
21
       hosId = '';
21
       hosId = '';
22
     }else{
22
     }else{
23
       // 其他页面
23
       // 其他页面

+ 19 - 1
src/app/views/login/login.component.ts

@@ -1,5 +1,5 @@
1
 import { Component, OnInit } from "@angular/core";
1
 import { Component, OnInit } from "@angular/core";
2
-import { Router } from "@angular/router";
2
+import { Router, NavigationStart } from "@angular/router";
3
 import { FormBuilder, Validators, FormGroup } from "@angular/forms";
3
 import { FormBuilder, Validators, FormGroup } from "@angular/forms";
4
 import { NzMessageService } from "ng-zorro-antd/message";
4
 import { NzMessageService } from "ng-zorro-antd/message";
5
 import { MainService } from "../../services/main.service";
5
 import { MainService } from "../../services/main.service";
@@ -19,6 +19,7 @@ export class LoginComponent implements OnInit {
19
   validateForm: FormGroup;
19
   validateForm: FormGroup;
20
   loading: boolean = false; // 加载状态
20
   loading: boolean = false; // 加载状态
21
   isSingleSignOn: boolean = false; // 是否单点登录
21
   isSingleSignOn: boolean = false; // 是否单点登录
22
+  rooterChange
22
   constructor(
23
   constructor(
23
     private router: Router,
24
     private router: Router,
24
     private fb: FormBuilder,
25
     private fb: FormBuilder,
@@ -28,12 +29,29 @@ export class LoginComponent implements OnInit {
28
     private titleService: Title,
29
     private titleService: Title,
29
     private markingService: MarkingService,
30
     private markingService: MarkingService,
30
   ) {}
31
   ) {}
32
+  ngOnDestroy() {
33
+    if (this.rooterChange) {
34
+      this.rooterChange.unsubscribe();
35
+    }
36
+  }
31
   ngOnInit() {
37
   ngOnInit() {
32
     this.http = http;
38
     this.http = http;
33
     this.isSingleSignOn = location.href.includes("?");
39
     this.isSingleSignOn = location.href.includes("?");
34
     if (this.isSingleSignOn) {
40
     if (this.isSingleSignOn) {
35
       this.singleSignOn();
41
       this.singleSignOn();
36
     } else {
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
       this.initForm();
55
       this.initForm();
38
     }
56
     }
39
   }
57
   }