diff --git a/src/utils/request.js b/src/utils/request.js index 980f8a1..9c2d1bf 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -1,18 +1,19 @@ /* * @Author: Do not edit * @Date: 2023-11-20 11:02:29 - * @LastEditTime: 2024-01-10 17:31:37 + * @LastEditTime: 2024-01-11 10:34:34 * @LastEditors: DY * @Description: */ import axios from 'axios' import { getTenantId, getAccessToken, getRefreshToken, setToken } from '@/utils/auth' import { refreshToken } from '@/api/login' +import { MessageBox } from 'element-ui' axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8' const service = axios.create({ - // baseURL: 'http://192.168.0.33:48082/admin-api', + // baseURL: 'http://192.168.1.78:48082/admin-api', baseURL: 'http://192.168.0.33:48082/admin-api', timeout: 30000, withCredentials: false @@ -53,13 +54,13 @@ service.interceptors.response.use(async res => { try { const refreshTokenRes = await refreshToken() // 2.1 刷新成功,则回放队列的请求 + 当前请求 - if (refreshTokenRes.data.code === 0) { - setToken(refreshTokenRes.data.data) - requestList.forEach(cb => cb()) - return service(res.config) - } else { - return handleAuthorized() - } + // if (refreshTokenRes.data.code === 0) { + setToken(refreshTokenRes.data.data) + requestList.forEach(cb => cb()) + return service(res.config) + // } else { + // return handleAuthorized() + // } } catch (e) { // 为什么需要 catch 异常呢?刷新失败时,请求因为 Promise.reject 触发异常。 // 2.2 刷新失败,只回放队列的请求 requestList.forEach(cb => cb()) @@ -87,22 +88,19 @@ service.interceptors.response.use(async res => { function handleAuthorized () { if (!isRelogin.show) { isRelogin.show = true - this.$message.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { + MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' } ).then(() => { isRelogin.show = false - this.$router.push({ path: '/' }) - // store.dispatch('LogOut').then(() => { - // location.href = getPath('/index'); - // }) + location.href = '' }).catch(() => { isRelogin.show = false }) } - return Promise.reject(new Error('无效的会话,或者会话已过期,请重新登录。')) + // return Promise.reject(new Error('无效的会话,或者会话已过期,请重新登录。')) } export default service diff --git a/src/views/Quality.vue b/src/views/Quality.vue index 144bf3e..883b942 100644 --- a/src/views/Quality.vue +++ b/src/views/Quality.vue @@ -1,7 +1,7 @@ @@ -112,12 +112,16 @@ export default { }, getLine () { lineList().then(res => { - this.lineArray = res.data.data.map(item => { - return { - text: item.name, - value: item.id - } - }) + if (res && res.data.data.length > 0) { + this.lineArray = res.data.data.map(item => { + return { + text: item.name, + value: item.id + } + }) + } else { + this.lineArray = [] + } }) }, getSection () {