瀏覽代碼

Merge branch 'bugfix-logout-err' into develop

master
JinxChen 2 年之前
父節點
當前提交
1f16bfa9da
共有 3 個文件被更改,包括 42 次插入29 次删除
  1. +8
    -3
      README.md
  2. +3
    -3
      src/utils/model.js
  3. +31
    -23
      src/utils/request.js

+ 8
- 3
README.md 查看文件

@@ -1,7 +1,7 @@
<!--
* @Date: 2021-11-29 11:14:13
* @LastEditors: JinxuChen
* @LastEditTime: 2022-01-11 14:14:32
* @LastEditors: JinxChen
* @LastEditTime: 2022-01-12 09:17:09
* @FilePath: \GpsCardAdmin\README.md
* @description:
-->
@@ -175,4 +175,9 @@ FIX
## v1.2.1F
`2021年1月11日`
FIX
- 修复 登录过期错误提示显示两次的问题
- 修复 登录过期错误提示显示两次的问题

## v1.2.2F
`2021年1月12日`
FIX
- 修复 登录过期没有跳转到登录界面的问题

+ 3
- 3
src/utils/model.js 查看文件

@@ -1,8 +1,8 @@
/*
* @Date: 2021-11-30 15:09:25
* @LastEditors: JinxuChen
* @LastEditTime: 2022-01-11 14:14:38
* @LastEditors: JinxChen
* @LastEditTime: 2022-01-12 09:18:47
* @FilePath: \GpsCardAdmin\src\utils\model.js
* @description: 版本号
*/
export const VersionModel = '1.2.1';
export const VersionModel = '1.2.2';

+ 31
- 23
src/utils/request.js 查看文件

@@ -1,12 +1,14 @@
/*
* @Date: 2021-12-08 15:59:46
* @LastEditors: JinxuChen
* @LastEditTime: 2022-01-11 14:25:43
* @LastEditors: JinxChen
* @LastEditTime: 2022-01-12 09:18:37
* @FilePath: \GpsCardAdmin\src\utils\request.js
* @description:
*/
import axios from 'axios'
import { Message } from 'element-ui'
import {
Message
} from 'element-ui'
import store from '@/store'
/* import { getToken } from '@/utils/auth' */

@@ -14,7 +16,7 @@ import store from '@/store'
const service = axios.create({
baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
// withCredentials: true, // send cookies when cross-domain requests
/* timeout: 5000 */// request timeout
/* timeout: 5000 */ // request timeout
})

// request interceptor
@@ -42,7 +44,7 @@ service.interceptors.response.use(
/**
* If you want to get http information such as headers or status
* Please return response => response
*/
*/

/**
* Determine the request status by custom code
@@ -53,30 +55,36 @@ service.interceptors.response.use(
const res = response.data

// if the custom code is not 20000, it is judged as an error.
if (res.code !== 0) {
/* if (res.code !== 0) {
Message({
message: res.message || '出错了,请联系管理员!',
type: 'error',
duration: 3 * 1000
})
// 106 token验证过期;
return Promise.reject(new Error(res.message))
} else if (res.code === 106) {
// to re-login
setTimeout(() => {
store.dispatch('user/resetToken').then(() => {
Message({
message: 'token过期,请重新登录',
type: 'error',
duration: 1500
})
location.reload()
})
}, 1500)
return Promise.reject(new Error('token过期,请重新登录'))
}
else {
} else */
if (res.code === 106) {
// to re-login
setTimeout(() => {
store.dispatch('user/resetToken').then(() => {
Message({
message: 'token过期,请重新登录',
type: 'error',
duration: 1500
})
location.reload()
})
}, 1500)
return Promise.reject(new Error('token过期,请重新登录'))
} else if (res.code === 0) {
return res
} else {
Message({
message: res.message || '出错了,请联系管理员!',
type: 'error',
duration: 3 * 1000
})
return Promise.reject(new Error(res.message))
}
},
error => {
@@ -86,7 +94,7 @@ service.interceptors.response.use(
type: 'error',
duration: 3 * 1000
})
/* return Promise.reject(error) */
return Promise.reject(error)
}
)



Loading…
取消
儲存