@uxda/appkit 1.0.62 → 1.0.64

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/dist/index.js CHANGED
@@ -234,13 +234,13 @@ const request = (config) => {
234
234
  method: config.method,
235
235
  success(res) {
236
236
  if (!isSuccess(res)) {
237
- console.error("\u63A5\u53E3\u62A5\u9519", res);
237
+ reject(`==\u63A5\u53E3\u62A5\u9519==${res.statusCode}`);
238
238
  reject({});
239
239
  }
240
240
  const { data: raw } = res;
241
241
  if (clientConfig.interceptors?.auth(raw)) {
242
242
  clientConfig.onAuthError?.();
243
- reject("--- 401 ---");
243
+ reject("===401===");
244
244
  }
245
245
  if (clientConfig.interceptors?.server(raw)) {
246
246
  clientConfig.onServerError?.();
@@ -250,7 +250,7 @@ const request = (config) => {
250
250
  if (response) {
251
251
  resolve(clientConfig.transforms && clientConfig.transforms[config.url] ? clientConfig.transforms[config.url](response) : response);
252
252
  } else {
253
- reject({});
253
+ reject(`==\u63A5\u53E3\u62A5\u9519==${raw.msg}`);
254
254
  }
255
255
  },
256
256
  fail(res) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxda/appkit",
3
- "version": "1.0.62",
3
+ "version": "1.0.64",
4
4
  "description": "小程序应用开发包",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.ts",
@@ -59,15 +59,18 @@ const request: Http['request'] = <T>(config: HttpRequestConfig) => {
59
59
  method: config.method,
60
60
  success (res: Taro.request.SuccessCallbackResult<ResponseRaw>) {
61
61
  if (!isSuccess(res)) {
62
- console.error('接口报错', res)
62
+ // 拦截 statusCode
63
+ reject(`==接口报错==${res.statusCode}`)
63
64
  reject({})
64
65
  }
65
66
  const { data: raw } = res
66
67
  if (clientConfig.interceptors?.auth(raw)) {
68
+ //拦截 401
67
69
  clientConfig.onAuthError?.()
68
- reject('--- 401 ---')
70
+ reject('===401===')
69
71
  }
70
72
  if (clientConfig.interceptors?.server(raw)) {
73
+ // 拦截后端错误
71
74
  clientConfig.onServerError?.()
72
75
  reject('server error')
73
76
  }
@@ -79,9 +82,8 @@ const request: Http['request'] = <T>(config: HttpRequestConfig) => {
79
82
  ? clientConfig.transforms[config.url](response) as T
80
83
  : response as T)
81
84
  } else {
82
- reject({
83
-
84
- })
85
+ // 拦截业务异常
86
+ reject(`==接口报错==${raw.msg}`)
85
87
  }
86
88
  },
87
89
  fail (res) {