byt-ui 0.1.13 → 0.1.15
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 +33 -50
- package/lib/byt-ui.umd.js +33 -50
- package/lib/byt-ui.umd.min.js +1 -1
- package/package.json +1 -1
- package/packages/common/modules/request.js +33 -48
package/lib/byt-ui.common.js
CHANGED
|
@@ -180208,6 +180208,7 @@ class request_Request {
|
|
|
180208
180208
|
'428': 'token过期,请重新登录',
|
|
180209
180209
|
'429': '请求过频繁',
|
|
180210
180210
|
'479': '演示环境,没有权限操作',
|
|
180211
|
+
'503': '服务未启动,请联系管理员处理',
|
|
180211
180212
|
'default': '系统未知错误,请反馈给管理员'
|
|
180212
180213
|
};
|
|
180213
180214
|
this._methods = ['get', 'post', 'delete', 'put'];
|
|
@@ -180216,15 +180217,20 @@ class request_Request {
|
|
|
180216
180217
|
baseURL: '/bytserver',
|
|
180217
180218
|
responseType: 'json',
|
|
180218
180219
|
timeout: 60000,
|
|
180219
|
-
|
|
180220
|
+
showError: true,
|
|
180221
|
+
withCredentials: false,
|
|
180222
|
+
validateStatus(status) {
|
|
180223
|
+
// >=200或者<=500的统一由成功拦截处理
|
|
180224
|
+
return status >= 200 && status <= 500; // 默认的
|
|
180225
|
+
}
|
|
180220
180226
|
}, options);
|
|
180221
|
-
this.
|
|
180227
|
+
this._request = lib_axios.create(this.options);
|
|
180222
180228
|
// 注册fetch;
|
|
180223
180229
|
this.register();
|
|
180224
180230
|
}
|
|
180225
180231
|
interceptors() {
|
|
180226
180232
|
// HTTPrequest拦截
|
|
180227
|
-
this.
|
|
180233
|
+
this._request.interceptors.request.use(config => {
|
|
180228
180234
|
const TENANT_ID = (0,cookie.getCookie)('tenantId');
|
|
180229
180235
|
const isToken = (config.headers || {}).isToken === false;
|
|
180230
180236
|
const token = (0,cookie.getCookie)('access_token');
|
|
@@ -180239,54 +180245,31 @@ class request_Request {
|
|
|
180239
180245
|
});
|
|
180240
180246
|
|
|
180241
180247
|
// HTTPresponse拦截
|
|
180242
|
-
this.
|
|
180248
|
+
this._request.interceptors.response.use(res => {
|
|
180243
180249
|
const status = Number(res.status) || 200;
|
|
180244
180250
|
const message = res.data.msg || this._errorCode[status] || this._errorCode['default'];
|
|
180245
|
-
|
|
180246
|
-
|
|
180247
|
-
|
|
180248
|
-
|
|
180249
|
-
|
|
180250
|
-
|
|
180251
|
-
|
|
180252
|
-
|
|
180253
|
-
|
|
180254
|
-
|
|
180255
|
-
// 后台定义 424||428 针对令牌过期的特殊响应码
|
|
180256
|
-
this.handler.expire && this.handler.expire(res.data);
|
|
180257
|
-
element_ui_common.Message.error(message);
|
|
180258
|
-
if (window.__POWERED_BY_QIANKUN__ && this._Vue) {
|
|
180259
|
-
const {
|
|
180260
|
-
outLogin
|
|
180261
|
-
} = this._Vue.prototype.$appCommon;
|
|
180262
|
-
outLogin && outLogin();
|
|
180263
|
-
}
|
|
180264
|
-
break;
|
|
180265
|
-
default:
|
|
180266
|
-
element_ui_common.Message.error(message);
|
|
180267
|
-
return Promise.reject(message);
|
|
180251
|
+
if (status == 424 || status == 428) {
|
|
180252
|
+
// 后台定义 424||428 针对令牌过期的特殊响应码
|
|
180253
|
+
this.handler.expire && this.handler.expire(res.data);
|
|
180254
|
+
if (window.__POWERED_BY_QIANKUN__ && this._Vue) {
|
|
180255
|
+
const {
|
|
180256
|
+
outLogin
|
|
180257
|
+
} = this._Vue.prototype.$appCommon;
|
|
180258
|
+
outLogin && outLogin();
|
|
180259
|
+
}
|
|
180260
|
+
return Promise.reject(res.data);
|
|
180268
180261
|
}
|
|
180262
|
+
if (status !== 200 || res.data.code === 1) {
|
|
180263
|
+
if (res.config.showError) element_ui_common.Message.error(message);
|
|
180264
|
+
return Promise.reject(res.data);
|
|
180265
|
+
}
|
|
180266
|
+
this.handler.success && this.handler.success(res.data);
|
|
180267
|
+
return res.data;
|
|
180269
180268
|
}, error => {
|
|
180270
180269
|
if (error.response) {
|
|
180271
|
-
const status = error.response.status
|
|
180270
|
+
// const status = error.response.status
|
|
180272
180271
|
const message = error.response.data.msg;
|
|
180273
|
-
|
|
180274
|
-
case 424:
|
|
180275
|
-
case 428:
|
|
180276
|
-
// 后台定义 424||428 针对令牌过期的特殊响应码
|
|
180277
|
-
this.handler.expire && this.handler.expire(error.response);
|
|
180278
|
-
element_ui_common.Message.error(message);
|
|
180279
|
-
if (window.__POWERED_BY_QIANKUN__ && this._Vue) {
|
|
180280
|
-
const {
|
|
180281
|
-
outLogin
|
|
180282
|
-
} = this._Vue.prototype.$appCommon;
|
|
180283
|
-
outLogin && outLogin();
|
|
180284
|
-
}
|
|
180285
|
-
break;
|
|
180286
|
-
default:
|
|
180287
|
-
if (error.config.showError) element_ui_common.Message.error(message);
|
|
180288
|
-
break;
|
|
180289
|
-
}
|
|
180272
|
+
if (error.config.showError) element_ui_common.Message.error(message);
|
|
180290
180273
|
this.handler.error && this.handler.error(error.response);
|
|
180291
180274
|
}
|
|
180292
180275
|
return Promise.reject(new Error(error));
|
|
@@ -180302,7 +180285,7 @@ class request_Request {
|
|
|
180302
180285
|
}
|
|
180303
180286
|
setMethods() {
|
|
180304
180287
|
this._methods.forEach(v => {
|
|
180305
|
-
this.
|
|
180288
|
+
this._request[v] = ({
|
|
180306
180289
|
url,
|
|
180307
180290
|
data = {},
|
|
180308
180291
|
params = {},
|
|
@@ -180312,7 +180295,7 @@ class request_Request {
|
|
|
180312
180295
|
showError
|
|
180313
180296
|
}) => {
|
|
180314
180297
|
return new Promise((resolve, reject) => {
|
|
180315
|
-
this.
|
|
180298
|
+
this._request({
|
|
180316
180299
|
url,
|
|
180317
180300
|
method: v.toUpperCase(),
|
|
180318
180301
|
data,
|
|
@@ -180330,7 +180313,7 @@ class request_Request {
|
|
|
180330
180313
|
// 重试请求
|
|
180331
180314
|
reject(err);
|
|
180332
180315
|
if (retry > 0) {
|
|
180333
|
-
this.
|
|
180316
|
+
this._request[v]({
|
|
180334
180317
|
url,
|
|
180335
180318
|
data,
|
|
180336
180319
|
params,
|
|
@@ -180355,9 +180338,9 @@ class request_Request {
|
|
|
180355
180338
|
}
|
|
180356
180339
|
const request_fetch = (config = {}, Vue) => {
|
|
180357
180340
|
const {
|
|
180358
|
-
|
|
180341
|
+
_request
|
|
180359
180342
|
} = new request_Request(Object.assign({}, config), Vue);
|
|
180360
|
-
return
|
|
180343
|
+
return _request;
|
|
180361
180344
|
};
|
|
180362
180345
|
/* harmony default export */ var request = ({
|
|
180363
180346
|
install(Vue, config = {}) {
|
package/lib/byt-ui.umd.js
CHANGED
|
@@ -180218,6 +180218,7 @@ class request_Request {
|
|
|
180218
180218
|
'428': 'token过期,请重新登录',
|
|
180219
180219
|
'429': '请求过频繁',
|
|
180220
180220
|
'479': '演示环境,没有权限操作',
|
|
180221
|
+
'503': '服务未启动,请联系管理员处理',
|
|
180221
180222
|
'default': '系统未知错误,请反馈给管理员'
|
|
180222
180223
|
};
|
|
180223
180224
|
this._methods = ['get', 'post', 'delete', 'put'];
|
|
@@ -180226,15 +180227,20 @@ class request_Request {
|
|
|
180226
180227
|
baseURL: '/bytserver',
|
|
180227
180228
|
responseType: 'json',
|
|
180228
180229
|
timeout: 60000,
|
|
180229
|
-
|
|
180230
|
+
showError: true,
|
|
180231
|
+
withCredentials: false,
|
|
180232
|
+
validateStatus(status) {
|
|
180233
|
+
// >=200或者<=500的统一由成功拦截处理
|
|
180234
|
+
return status >= 200 && status <= 500; // 默认的
|
|
180235
|
+
}
|
|
180230
180236
|
}, options);
|
|
180231
|
-
this.
|
|
180237
|
+
this._request = lib_axios.create(this.options);
|
|
180232
180238
|
// 注册fetch;
|
|
180233
180239
|
this.register();
|
|
180234
180240
|
}
|
|
180235
180241
|
interceptors() {
|
|
180236
180242
|
// HTTPrequest拦截
|
|
180237
|
-
this.
|
|
180243
|
+
this._request.interceptors.request.use(config => {
|
|
180238
180244
|
const TENANT_ID = (0,cookie.getCookie)('tenantId');
|
|
180239
180245
|
const isToken = (config.headers || {}).isToken === false;
|
|
180240
180246
|
const token = (0,cookie.getCookie)('access_token');
|
|
@@ -180249,54 +180255,31 @@ class request_Request {
|
|
|
180249
180255
|
});
|
|
180250
180256
|
|
|
180251
180257
|
// HTTPresponse拦截
|
|
180252
|
-
this.
|
|
180258
|
+
this._request.interceptors.response.use(res => {
|
|
180253
180259
|
const status = Number(res.status) || 200;
|
|
180254
180260
|
const message = res.data.msg || this._errorCode[status] || this._errorCode['default'];
|
|
180255
|
-
|
|
180256
|
-
|
|
180257
|
-
|
|
180258
|
-
|
|
180259
|
-
|
|
180260
|
-
|
|
180261
|
-
|
|
180262
|
-
|
|
180263
|
-
|
|
180264
|
-
|
|
180265
|
-
// 后台定义 424||428 针对令牌过期的特殊响应码
|
|
180266
|
-
this.handler.expire && this.handler.expire(res.data);
|
|
180267
|
-
element_ui_common.Message.error(message);
|
|
180268
|
-
if (window.__POWERED_BY_QIANKUN__ && this._Vue) {
|
|
180269
|
-
const {
|
|
180270
|
-
outLogin
|
|
180271
|
-
} = this._Vue.prototype.$appCommon;
|
|
180272
|
-
outLogin && outLogin();
|
|
180273
|
-
}
|
|
180274
|
-
break;
|
|
180275
|
-
default:
|
|
180276
|
-
element_ui_common.Message.error(message);
|
|
180277
|
-
return Promise.reject(message);
|
|
180261
|
+
if (status == 424 || status == 428) {
|
|
180262
|
+
// 后台定义 424||428 针对令牌过期的特殊响应码
|
|
180263
|
+
this.handler.expire && this.handler.expire(res.data);
|
|
180264
|
+
if (window.__POWERED_BY_QIANKUN__ && this._Vue) {
|
|
180265
|
+
const {
|
|
180266
|
+
outLogin
|
|
180267
|
+
} = this._Vue.prototype.$appCommon;
|
|
180268
|
+
outLogin && outLogin();
|
|
180269
|
+
}
|
|
180270
|
+
return Promise.reject(res.data);
|
|
180278
180271
|
}
|
|
180272
|
+
if (status !== 200 || res.data.code === 1) {
|
|
180273
|
+
if (res.config.showError) element_ui_common.Message.error(message);
|
|
180274
|
+
return Promise.reject(res.data);
|
|
180275
|
+
}
|
|
180276
|
+
this.handler.success && this.handler.success(res.data);
|
|
180277
|
+
return res.data;
|
|
180279
180278
|
}, error => {
|
|
180280
180279
|
if (error.response) {
|
|
180281
|
-
const status = error.response.status
|
|
180280
|
+
// const status = error.response.status
|
|
180282
180281
|
const message = error.response.data.msg;
|
|
180283
|
-
|
|
180284
|
-
case 424:
|
|
180285
|
-
case 428:
|
|
180286
|
-
// 后台定义 424||428 针对令牌过期的特殊响应码
|
|
180287
|
-
this.handler.expire && this.handler.expire(error.response);
|
|
180288
|
-
element_ui_common.Message.error(message);
|
|
180289
|
-
if (window.__POWERED_BY_QIANKUN__ && this._Vue) {
|
|
180290
|
-
const {
|
|
180291
|
-
outLogin
|
|
180292
|
-
} = this._Vue.prototype.$appCommon;
|
|
180293
|
-
outLogin && outLogin();
|
|
180294
|
-
}
|
|
180295
|
-
break;
|
|
180296
|
-
default:
|
|
180297
|
-
if (error.config.showError) element_ui_common.Message.error(message);
|
|
180298
|
-
break;
|
|
180299
|
-
}
|
|
180282
|
+
if (error.config.showError) element_ui_common.Message.error(message);
|
|
180300
180283
|
this.handler.error && this.handler.error(error.response);
|
|
180301
180284
|
}
|
|
180302
180285
|
return Promise.reject(new Error(error));
|
|
@@ -180312,7 +180295,7 @@ class request_Request {
|
|
|
180312
180295
|
}
|
|
180313
180296
|
setMethods() {
|
|
180314
180297
|
this._methods.forEach(v => {
|
|
180315
|
-
this.
|
|
180298
|
+
this._request[v] = ({
|
|
180316
180299
|
url,
|
|
180317
180300
|
data = {},
|
|
180318
180301
|
params = {},
|
|
@@ -180322,7 +180305,7 @@ class request_Request {
|
|
|
180322
180305
|
showError
|
|
180323
180306
|
}) => {
|
|
180324
180307
|
return new Promise((resolve, reject) => {
|
|
180325
|
-
this.
|
|
180308
|
+
this._request({
|
|
180326
180309
|
url,
|
|
180327
180310
|
method: v.toUpperCase(),
|
|
180328
180311
|
data,
|
|
@@ -180340,7 +180323,7 @@ class request_Request {
|
|
|
180340
180323
|
// 重试请求
|
|
180341
180324
|
reject(err);
|
|
180342
180325
|
if (retry > 0) {
|
|
180343
|
-
this.
|
|
180326
|
+
this._request[v]({
|
|
180344
180327
|
url,
|
|
180345
180328
|
data,
|
|
180346
180329
|
params,
|
|
@@ -180365,9 +180348,9 @@ class request_Request {
|
|
|
180365
180348
|
}
|
|
180366
180349
|
const request_fetch = (config = {}, Vue) => {
|
|
180367
180350
|
const {
|
|
180368
|
-
|
|
180351
|
+
_request
|
|
180369
180352
|
} = new request_Request(Object.assign({}, config), Vue);
|
|
180370
|
-
return
|
|
180353
|
+
return _request;
|
|
180371
180354
|
};
|
|
180372
180355
|
/* harmony default export */ var request = ({
|
|
180373
180356
|
install(Vue, config = {}) {
|