From ecdff0d7764b810640fad072f3a9fb69d78dc7db Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@iotlink.com>
Date: 星期一, 27 七月 2020 17:43:10 +0800
Subject: [PATCH] 桌面添加token过期的跳转到登陆页的处理.应用通过postMessage通知桌面

---
 src/scripts/httpRequest.ts                    |    5 ++++-
 src/pages/desktop/index/components/DFrame.vue |    7 +++++++
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/src/pages/desktop/index/components/DFrame.vue b/src/pages/desktop/index/components/DFrame.vue
index ae56e08..f7c5feb 100644
--- a/src/pages/desktop/index/components/DFrame.vue
+++ b/src/pages/desktop/index/components/DFrame.vue
@@ -39,6 +39,13 @@
       height: this.data.height || 512
     }
   },
+  mounted() {
+    window.addEventListener('message', e => {
+      if (e.data && e.data.msg == "logout") {
+        location.assign("/");
+      }
+    })
+  },
   methods: {
     closeFrame: function () {
       this.$store.dispatch('desktop/closeFrame', this.data);
diff --git a/src/scripts/httpRequest.ts b/src/scripts/httpRequest.ts
index 66c2d6b..846a592 100644
--- a/src/scripts/httpRequest.ts
+++ b/src/scripts/httpRequest.ts
@@ -55,7 +55,6 @@
   res => {
     /* //瀵瑰搷搴旀暟鎹仛浜涗簨 */
     if (res.data && res.statusText !== 'OK' && res.status !== 200) {
-      console.log('鍚浣犲鐩稿簲鏁版嵁鍋氫簡浜涗簨', res)
       Notification({
         title: '',
         message: res.data.message,
@@ -77,6 +76,7 @@
     // } else {
     //   window.sessionStorage.setItem('policeCameravideoIsLoginTimeout', JSON.stringify(true))
     // }
+
     return res.data ? res.data : {}
 
     /* //return res.data ? res.data : {}; */
@@ -95,6 +95,9 @@
         case 401:
           errJson.status = error.response.status
           errJson.message = '鏈巿鏉冿紝璇烽噸鏂扮櫥褰�(401)'
+          window.parent.postMessage({
+            msg: "logout"
+          }, '*')
           // console.log("鏍囧織浣嶏細",AuthData.isLoginout)
           // if (!AuthData.isLoginout) {
           //   Notification({

--
Gitblit v1.8.0