byt-ui 0.1.12 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/byt-ui.common.js +24 -35
- package/lib/byt-ui.umd.js +24 -35
- package/lib/byt-ui.umd.min.js +1 -1
- package/package.json +1 -1
- package/packages/common/modules/request.js +23 -33
package/package.json
CHANGED
|
@@ -54,39 +54,27 @@ class Request {
|
|
|
54
54
|
this.request.interceptors.response.use(res => {
|
|
55
55
|
const status = Number(res.status) || 200
|
|
56
56
|
const message = res.data.msg || this._errorCode[status] || this._errorCode['default']
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
Message.error(message);
|
|
70
|
-
if (window.__POWERED_BY_QIANKUN__ && this._Vue) {
|
|
71
|
-
const { outLogin } = this._Vue.prototype.$appCommon;
|
|
72
|
-
outLogin && outLogin();
|
|
73
|
-
}
|
|
74
|
-
break;
|
|
75
|
-
default:
|
|
76
|
-
Message.error(message);
|
|
77
|
-
return Promise.reject(message)
|
|
57
|
+
if (status == 424 || status == 428) {
|
|
58
|
+
// 后台定义 424||428 针对令牌过期的特殊响应码
|
|
59
|
+
this.handler.expire && this.handler.expire(res.data);
|
|
60
|
+
if (window.__POWERED_BY_QIANKUN__ && this._Vue) {
|
|
61
|
+
const { outLogin } = this._Vue.prototype.$appCommon;
|
|
62
|
+
outLogin && outLogin();
|
|
63
|
+
}
|
|
64
|
+
return res.data
|
|
65
|
+
}
|
|
66
|
+
if (status !== 200 || res.data.code === 1) {
|
|
67
|
+
if (res.config.showError) Message.error(message)
|
|
68
|
+
return Promise.reject(res.data)
|
|
78
69
|
}
|
|
70
|
+
|
|
71
|
+
this.handler.success && this.handler.success(res.data);
|
|
72
|
+
return res.data
|
|
79
73
|
}, error => {
|
|
80
74
|
if (error.response) {
|
|
81
|
-
const status = error.response.status
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
Message.error(this._errorCode[status])
|
|
85
|
-
break;
|
|
86
|
-
case 503:
|
|
87
|
-
Message.error(error.response.data.msg)
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
75
|
+
// const status = error.response.status
|
|
76
|
+
const message = error.response.data.msg;
|
|
77
|
+
if (error.config.showError)Message.error(message)
|
|
90
78
|
this.handler.error && this.handler.error(error.response);
|
|
91
79
|
}
|
|
92
80
|
return Promise.reject(new Error(error))
|
|
@@ -109,7 +97,8 @@ class Request {
|
|
|
109
97
|
params = {},
|
|
110
98
|
responseType = 'json',
|
|
111
99
|
headers = {},
|
|
112
|
-
retry = 0
|
|
100
|
+
retry = 0,
|
|
101
|
+
showError
|
|
113
102
|
}) => {
|
|
114
103
|
return new Promise((resolve, reject) => {
|
|
115
104
|
this.request({
|
|
@@ -128,7 +117,7 @@ class Request {
|
|
|
128
117
|
) {
|
|
129
118
|
resolve(res)
|
|
130
119
|
} else {
|
|
131
|
-
Message.error(res.msg)
|
|
120
|
+
if (showError)Message.error(res.msg)
|
|
132
121
|
reject(res)
|
|
133
122
|
}
|
|
134
123
|
}).catch(err => {
|
|
@@ -141,7 +130,8 @@ class Request {
|
|
|
141
130
|
params,
|
|
142
131
|
responseType,
|
|
143
132
|
headers,
|
|
144
|
-
retry: retry - 1
|
|
133
|
+
retry: retry - 1,
|
|
134
|
+
showError
|
|
145
135
|
})
|
|
146
136
|
}
|
|
147
137
|
})
|