From e310229fe9ebf86b3920adf16492f286c976e6c1 Mon Sep 17 00:00:00 2001
From: ZhengJie <201507802@qq.com>
Date: Mon, 9 Nov 2020 20:08:59 +0800
Subject: [PATCH 1/2] =?UTF-8?q?[=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96](v2.6?=
=?UTF-8?q?)=EF=BC=9Aupdate=20=E6=96=87=E6=A1=A3=E5=9C=B0=E5=9D=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 46719d6..1feb505 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ ELADMIN 前端源码
| 码云 | https://gitee.com/elunez/eladmin | https://gitee.com/elunez/eladmin-web |
#### 开发文档
-[https://doc.el-admin.xin](https://doc.el-admin.xin)
+[https://el-admin.vip](https://el-admin.vip)
#### 前端模板
@@ -63,4 +63,4 @@ https://www.ydyno.com/archives/1219.html
#### 反馈交流
-- QQ交流群:一群:891137268 已满、二群:947578238 无需验证,直接加入
\ No newline at end of file
+- QQ交流群:一群:891137268 已满、二群:947578238
\ No newline at end of file
From c9a8b708bb350e344f94fc00f23b4e8d721e5bd1 Mon Sep 17 00:00:00 2001
From: ZhengJie <201507802@qq.com>
Date: Sun, 15 Nov 2020 14:33:01 +0800
Subject: [PATCH 2/2] =?UTF-8?q?[=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96](v2.6?=
=?UTF-8?q?)=EF=BC=9A=E4=BF=AE=E5=A4=8D=20responseType=20=E4=B8=BA=20blob?=
=?UTF-8?q?=20=E6=97=B6=E6=97=A0=E6=B3=95=E8=A7=A3=E6=9E=90=E5=90=8E?=
=?UTF-8?q?=E5=8F=B0=E8=BF=94=E5=9B=9E=E7=9A=84=E9=94=99=E8=AF=AF=E4=BF=A1?=
=?UTF-8?q?=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
close https://github.com/elunez/eladmin/issues/524
---
src/utils/request.js | 86 +++++++++++++++++++++++---------------------
1 file changed, 45 insertions(+), 41 deletions(-)
diff --git a/src/utils/request.js b/src/utils/request.js
index 9cf0155..ce7fd1b 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -22,8 +22,6 @@ service.interceptors.request.use(
return config
},
error => {
- // Do something with request error
- console.log(error) // for debug
Promise.reject(error)
}
)
@@ -31,52 +29,58 @@ service.interceptors.request.use(
// response 拦截器
service.interceptors.response.use(
response => {
- const code = response.status
- if (code < 200 || code > 300) {
- Notification.error({
- title: response.message
- })
- return Promise.reject('error')
- } else {
- return response.data
- }
+ return response.data
},
error => {
- let code = 0
- try {
- code = error.response.data.status
- } catch (e) {
- if (error.toString().indexOf('Error: timeout') !== -1) {
+ // 兼容blob下载出错json提示
+ if (error.response.data instanceof Blob && error.response.data.type.toLowerCase().indexOf('json') !== -1) {
+ const reader = new FileReader()
+ reader.readAsText(error.response.data, 'utf-8')
+ reader.onload = function(e) {
+ const errorMsg = JSON.parse(reader.result).message
Notification.error({
- title: '网络请求超时',
+ title: errorMsg,
duration: 5000
})
- return Promise.reject(error)
- }
- }
- if (code) {
- if (code === 401) {
- store.dispatch('LogOut').then(() => {
- // 用户登录界面提示
- Cookies.set('point', 401)
- location.reload()
- })
- } else if (code === 403) {
- router.push({ path: '/401' })
- } else {
- const errorMsg = error.response.data.message
- if (errorMsg !== undefined) {
- Notification.error({
- title: errorMsg,
- duration: 5000
- })
- }
}
} else {
- Notification.error({
- title: '接口请求失败',
- duration: 5000
- })
+ let code = 0
+ try {
+ code = error.response.data.status
+ } catch (e) {
+ if (error.toString().indexOf('Error: timeout') !== -1) {
+ Notification.error({
+ title: '网络请求超时',
+ duration: 5000
+ })
+ return Promise.reject(error)
+ }
+ }
+ console.log(code)
+ if (code) {
+ if (code === 401) {
+ store.dispatch('LogOut').then(() => {
+ // 用户登录界面提示
+ Cookies.set('point', 401)
+ location.reload()
+ })
+ } else if (code === 403) {
+ router.push({ path: '/401' })
+ } else {
+ const errorMsg = error.response.data.message
+ if (errorMsg !== undefined) {
+ Notification.error({
+ title: errorMsg,
+ duration: 5000
+ })
+ }
+ }
+ } else {
+ Notification.error({
+ title: '接口请求失败',
+ duration: 5000
+ })
+ }
}
return Promise.reject(error)
}