diff --git a/README.md b/README.md index 11ee4f6..1e96214 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ @@ -175,4 +175,9 @@ FIX ## v1.2.1F `2021年1月11日` FIX -- 修复 登录过期错误提示显示两次的问题 \ No newline at end of file +- 修复 登录过期错误提示显示两次的问题 + +## v1.2.2F +`2021年1月12日` +FIX +- 修复 登录过期没有跳转到登录界面的问题 \ No newline at end of file diff --git a/src/utils/model.js b/src/utils/model.js index 6f9ff9f..1d5dff0 100644 --- a/src/utils/model.js +++ b/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'; \ No newline at end of file +export const VersionModel = '1.2.2'; \ No newline at end of file diff --git a/src/utils/request.js b/src/utils/request.js index 18b58fe..ad4138c 100644 --- a/src/utils/request.js +++ b/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) } )