byt-ui 0.1.13 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "byt-ui",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "private": false,
5
5
  "description": "byt组件库",
6
6
  "author": {
@@ -54,47 +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
- switch (status * 1) {
58
- case 200:
59
- if (res.data.code === 1) {
60
- Message.error(message)
61
- return Promise.reject(res.data)
62
- }
63
- this.handler.success && this.handler.success(res.data);
64
- return res.data
65
- case 424:
66
- case 428:
67
- // 后台定义 424||428 针对令牌过期的特殊响应码
68
- this.handler.expire && this.handler.expire(res.data);
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
75
+ // const status = error.response.status
82
76
  const message = error.response.data.msg;
83
- switch (status) {
84
- case 424:
85
- case 428:
86
- // 后台定义 424||428 针对令牌过期的特殊响应码
87
- this.handler.expire && this.handler.expire(error.response);
88
- Message.error(message);
89
- if (window.__POWERED_BY_QIANKUN__ && this._Vue) {
90
- const { outLogin } = this._Vue.prototype.$appCommon;
91
- outLogin && outLogin();
92
- }
93
- break;
94
- default:
95
- if (error.config.showError)Message.error(message)
96
- break;
97
- }
77
+ if (error.config.showError)Message.error(message)
98
78
  this.handler.error && this.handler.error(error.response);
99
79
  }
100
80
  return Promise.reject(new Error(error))