@tushi11/elpis 1.0.33 → 1.0.34

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.
@@ -76,11 +76,7 @@ const axiosHooks = {
76
76
  async responseInterceptorsHook(response) {
77
77
  NProgress.done();
78
78
  // 从请求配置的自定义选项中获取响应处理开关
79
- const {
80
- responseType = 'dtoResponse',
81
- showLoading,
82
- showMsgError,
83
- } = response?.config?.requestOptions;
79
+ const { responseType = 'dtoResponse', showLoading } = response?.config?.requestOptions;
84
80
 
85
81
  // 关闭全局加载中
86
82
  if (showLoading) {
@@ -145,9 +141,7 @@ const axiosHooks = {
145
141
  };
146
142
 
147
143
  const errorMsg = errorMessages[code] || errorMessages.default;
148
- if (showMsgError) {
149
- feedback.msgError(errorMsg);
150
- }
144
+ feedback.msgError(errorMsg);
151
145
  return Promise.resolve({ success: false, code, message: errorMsg });
152
146
  }
153
147
  // async 函数会自动将 “非 Promise 返回值” 用 Promise.resolve() 包装,因此 return 普通对象 等价于 return Promise.resolve(普通对象) // return 普通对象 更简洁(少写冗余代码),且语义清晰
@@ -166,6 +160,10 @@ const axiosHooks = {
166
160
  feedback.closeLoading();
167
161
 
168
162
  if (!error.isCancel) {
163
+ if (error.message.includes('code 401')) {
164
+ console.log(error.message);
165
+ return;
166
+ }
169
167
  // 排除主动取消请求的错误(避免误提示)
170
168
  error.message && feedback.msgError(error.message);
171
169
  } else {
@@ -181,7 +179,7 @@ const axiosHooks = {
181
179
  * 可通过请求时的自定义配置覆盖默认值
182
180
  */
183
181
  const {
184
- requestSetting: { timeout, proxyIndex, proxyOption = [], showMsgError = true } = {},
182
+ requestSetting: { timeout, proxyIndex, proxyOption = [] } = {},
185
183
  sysSetting: { version } = {},
186
184
  } = pageConfigs;
187
185
  const proxyConfig = proxyOption[proxyIndex] || {};
@@ -206,7 +204,6 @@ const defaultOptions = {
206
204
  retryCount: 2, // 最大重试次数(默认2次)
207
205
  showLoading: false, // 是否显示全局的加载中(默认不显示)
208
206
  loadingText: 'Loading...', // 加载中的提示文字
209
- showMsgError, // 是否显示错误消息(默认显示)
210
207
  },
211
208
  };
212
209
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tushi11/elpis",
3
- "version": "1.0.33",
3
+ "version": "1.0.34",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -17,6 +17,7 @@
17
17
  "@babel/core": "^7.24.0",
18
18
  "@babel/plugin-transform-runtime": "^7.1.0",
19
19
  "@babel/preset-env": "^7.4.5",
20
+ "@babel/runtime": "^7.28.4",
20
21
  "@element-plus/icons-vue": "^2.3.1",
21
22
  "@iconify-json/ep": "^1.2.3",
22
23
  "@iconify-json/mdi": "^1.2.3",
@@ -48,6 +49,7 @@
48
49
  "koa": "2.7.0",
49
50
  "koa-bodyparser": "^4.2.1",
50
51
  "koa-nunjucks-2": "^3.0.2",
52
+ "koa-proxy": "^1.0.0-alpha.3",
51
53
  "koa-router": "^7.4.0",
52
54
  "koa-static": "^5.0.0",
53
55
  "koa-useragent": "2.0.0",
@@ -68,7 +70,6 @@
68
70
  "postcss": "^8.4.41",
69
71
  "postcss-loader": "^8.1.1",
70
72
  "postcss-pxtorem": "^6.1.0",
71
- "koa-proxy": "^1.0.0-alpha.3",
72
73
  "sass": "^1.77.8",
73
74
  "sass-loader": "^16.0.5",
74
75
  "style-loader": "^0.14.1",