Просмотр исходного кода

fix: 新增201状态码处理逻辑并修复登录过期提示

1. 在响应拦截器中添加对201状态码的直接处理
2. 在学生页面接口请求中添加201状态码判断,显示登录过期提示
3. 移除冗余的登录过期提示注释代码
lsc 2 дней назад
Родитель
Сommit
2d79a625d7
2 измененных файлов с 8 добавлено и 1 удалено
  1. 4 0
      src/services/config.ts
  2. 4 1
      src/views/Student/index.vue

+ 4 - 0
src/services/config.ts

@@ -81,6 +81,10 @@ instance.interceptors.response.use(
   (response) => {
   (response) => {
     console.log('响应数据')
     console.log('响应数据')
     console.log(response)
     console.log(response)
+
+    if (response.status == 201) {
+      return Promise.resolve(response.status)
+    }
     if (response.status >= 200 && response.status < 400) {
     if (response.status >= 200 && response.status < 400) {
       return Promise.resolve(response.data)
       return Promise.resolve(response.data)
     }
     }

+ 4 - 1
src/views/Student/index.vue

@@ -3916,6 +3916,10 @@ const addOp3 = async (userTime: any, loadTime: any, object: any, status: any) =>
       const res = await axios.get('https://pbl.cocorobo.cn/api/pbl/selectUser', {
       const res = await axios.get('https://pbl.cocorobo.cn/api/pbl/selectUser', {
         params: { userid: props.userid }
         params: { userid: props.userid }
       })
       })
+      if (res == 201) {
+        message.error('登录已过期,请重新登录')
+        return
+      }
       userJson.value = res[0][0]
       userJson.value = res[0][0]
       console.log(userJson.value)
       console.log(userJson.value)
       console.log(res[0][0])
       console.log(res[0][0])
@@ -3924,7 +3928,6 @@ const addOp3 = async (userTime: any, loadTime: any, object: any, status: any) =>
   catch (e) {
   catch (e) {
     console.log(e)
     console.log(e)
     if (e === 123) {
     if (e === 123) {
-      // message.error('登录已过期,请重新登录')
       return
       return
     }
     }
     setTimeout(() => {
     setTimeout(() => {