黄梓星 1 рік тому
батько
коміт
7db555f695
1 змінених файлів з 13 додано та 1 видалено
  1. 13 1
      src/utils/request.js

+ 13 - 1
src/utils/request.js

@@ -1,11 +1,12 @@
 import axios from "axios";
 import { Notification, MessageBox, Message, Loading } from "element-ui";
 import store from "@/store";
-import { getToken } from "@/utils/auth";
+import { getToken, setToken } from "@/utils/auth";
 import errorCode from "@/utils/errorCode";
 import { tansParams, blobValidate } from "@/utils/ruoyi";
 import cache from "@/plugins/cache";
 import { saveAs } from "file-saver";
+import { sso } from '@/api/sso/ssoLogin';
 
 let downloadLoadingInstance;
 // 是否显示重新登录
@@ -100,6 +101,17 @@ service.interceptors.response.use(
     ) {
       return res.data;
     }
+    if (code === 222) {
+      let userInfo = JSON.parse(localStorage.getItem('userInfo'))
+      sso(userInfo).then(res => {
+        if (res.code === 200) {
+          let token = res.token
+          setToken(token)
+          this.$store.commit('SET_TOKEN', token)
+          this.$store.dispatch("GetInfo").then(() => { })
+        }
+      })
+    }
     if (code === 401) {
       if (!isRelogin.show) {
         isRelogin.show = true;