Parcourir la source

接口401情况下,页面关闭处理

wangrulan il y a 2 ans
Parent
commit
c6b7d29277

+ 1 - 1
src/components/home/index.vue

@@ -41,6 +41,7 @@ export default {
   computed: {},
   watch: {},
   created() {
+    console.log(this.$route);
     this.init();
   },
   methods: {
@@ -56,7 +57,6 @@ export default {
       });
     },
     jump(val) {
-      console.log('val----: ', val);
       let routeUrl = this.$router.resolve({
         // path: "/permissions/role",
         path:val.url,

+ 0 - 1
src/components/permissions/role/index.vue

@@ -83,7 +83,6 @@ export default {
   computed: {},
   watch: {},
   created() {
-    console.log(this.$router);
     this.init();
     this.getList();
   },

+ 10 - 8
src/utils/request.js

@@ -59,25 +59,27 @@ service.interceptors.response.use(res => {
     const code = res.data.code || 200;
     // 获取错误信息
     const msg = errorCode[code] || res.data.msg || errorCode['default']
-    if (code === 401) {
-      MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', {
-          confirmButtonText: '重新登录',
+    console.log('code: ', code);
+    if (code == 401) {
+      MessageBox.confirm('登录状态已过期,您可以关闭当前页面,刷新首页', '系统提示', {
+          confirmButtonText: '关闭当前页面',
           cancelButtonText: '取消',
           type: 'warning'
         }
       ).then(() => {
-        store.dispatch('LogOut').then(() => {
-          this.$router.push({ path: '/login' })
-        })
+        window.opener = null;
+        window.open("about:blank", "_top").close()
+        this.$router.push({path: "/home"});
+        location.reload()
       }).catch(() => {});
-      return Promise.reject()
+      // return Promise.reject()
     } else if (code === 500) {
       Message({
         message: msg,
         type: 'error'
       })
       return Promise.reject(new Error(msg))
-    } else if (code !== 200 && code != 1) {
+    }else if (code !== 200 && code != 1) {
       Notification.error({
         title: msg
       })