@uxda/appkit 4.2.78 → 4.2.80

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
@@ -504,6 +504,35 @@ function useLogger(options) {
504
504
  };
505
505
  }
506
506
 
507
+ function useWxAuth() {
508
+ function toWxAuth(source, redirectUri) {
509
+ const $http = useHttp$2();
510
+ $http.get("/cas/auth/render/", {
511
+ source,
512
+ redirectUri
513
+ }).then((res) => {
514
+ location.replace(res);
515
+ });
516
+ }
517
+ async function toCallbackLogin({ code, state, source }, cb) {
518
+ const $http = useHttp$2();
519
+ const res = await $http.post(
520
+ `/cas/auth/callbackLogin/${source}`,
521
+ { code, state, source },
522
+ {
523
+ "Content-Type": "application/x-www-form-urlencoded"
524
+ }
525
+ );
526
+ if (res) {
527
+ cb && cb(res);
528
+ }
529
+ }
530
+ return {
531
+ toWxAuth,
532
+ toCallbackLogin
533
+ };
534
+ }
535
+
507
536
  const _hoisted_1$E = {
508
537
  key: 0,
509
538
  class: "page-title"
@@ -924,6 +953,13 @@ const vendor$3 = {
924
953
  header,
925
954
  data: config.data
926
955
  }).then(({ data }) => {
956
+ const endTime = (/* @__PURE__ */ new Date()).getTime();
957
+ logger$3.info({
958
+ send: JSON.stringify({ url: config.url, data: config.data }),
959
+ receive: JSON.stringify(data),
960
+ traceId: header.traceId,
961
+ duration: endTime - startTime
962
+ });
927
963
  if (data.success) {
928
964
  resolve({
929
965
  status: +data.code,
@@ -936,13 +972,6 @@ const vendor$3 = {
936
972
  icon: "none"
937
973
  });
938
974
  }
939
- const endTime = (/* @__PURE__ */ new Date()).getTime();
940
- logger$3.info({
941
- send: JSON.stringify({ url: config.url, data: config.data }),
942
- receive: JSON.stringify(data),
943
- traceId: header.traceId,
944
- duration: endTime - startTime
945
- });
946
975
  }).catch((e) => {
947
976
  reject(e);
948
977
  });
@@ -1414,11 +1443,12 @@ const get = (url, data) => {
1414
1443
  method: HttpMethod.get
1415
1444
  });
1416
1445
  };
1417
- const post = (url, data) => {
1446
+ const post = (url, data, headers) => {
1418
1447
  return request({
1419
1448
  url,
1420
1449
  data,
1421
- method: HttpMethod.post
1450
+ method: HttpMethod.post,
1451
+ headers
1422
1452
  });
1423
1453
  };
1424
1454
  const defaultClientConfig = {
@@ -1544,6 +1574,13 @@ const vendor$2 = {
1544
1574
  header,
1545
1575
  data: config.data
1546
1576
  }).then(({ data }) => {
1577
+ const endTime = (/* @__PURE__ */ new Date()).getTime();
1578
+ logger$2.info({
1579
+ send: JSON.stringify({ url: config.url, data: config.data }),
1580
+ receive: JSON.stringify(data),
1581
+ traceId: header.traceId,
1582
+ duration: endTime - startTime
1583
+ });
1547
1584
  if (data.success) {
1548
1585
  resolve({
1549
1586
  status: +data.code,
@@ -1556,13 +1593,6 @@ const vendor$2 = {
1556
1593
  icon: "none"
1557
1594
  });
1558
1595
  }
1559
- const endTime = (/* @__PURE__ */ new Date()).getTime();
1560
- logger$2.info({
1561
- send: JSON.stringify({ url: config.url, data: config.data }),
1562
- receive: JSON.stringify(data),
1563
- traceId: header.traceId,
1564
- duration: endTime - startTime
1565
- });
1566
1596
  }).catch((e) => {
1567
1597
  reject(e);
1568
1598
  });
@@ -4916,6 +4946,13 @@ const vendor$1 = {
4916
4946
  header,
4917
4947
  data: config.data
4918
4948
  }).then(({ data }) => {
4949
+ const endTime = (/* @__PURE__ */ new Date()).getTime();
4950
+ logger$1.info({
4951
+ send: JSON.stringify({ url: config.url, data: config.data }),
4952
+ receive: JSON.stringify(data),
4953
+ traceId: header.traceId,
4954
+ duration: endTime - startTime
4955
+ });
4919
4956
  if (data.success) {
4920
4957
  resolve({
4921
4958
  status: +data.code,
@@ -4928,13 +4965,6 @@ const vendor$1 = {
4928
4965
  icon: "none"
4929
4966
  });
4930
4967
  }
4931
- const endTime = (/* @__PURE__ */ new Date()).getTime();
4932
- logger$1.info({
4933
- send: JSON.stringify({ url: config.url, data: config.data }),
4934
- receive: JSON.stringify(data),
4935
- traceId: header.traceId,
4936
- duration: endTime - startTime
4937
- });
4938
4968
  }).catch((e) => {
4939
4969
  reject(e);
4940
4970
  });
@@ -4990,7 +5020,8 @@ const _hoisted_2$c = { style: { "white-space": "pre-wrap" } };
4990
5020
  var script$i = /* @__PURE__ */ defineComponent({
4991
5021
  __name: "NoticePopup",
4992
5022
  props: {
4993
- message: { type: null, required: true, default: {} }
5023
+ message: { type: null, required: true, default: {} },
5024
+ device: { type: String, required: false, default: "MINI" }
4994
5025
  },
4995
5026
  emits: ["close", "view"],
4996
5027
  setup(__props, { emit: __emit }) {
@@ -5009,7 +5040,7 @@ var script$i = /* @__PURE__ */ defineComponent({
5009
5040
  async function onClose() {
5010
5041
  const $http = useHttp$1();
5011
5042
  $http.post("/cas/msg/setMsgStatus", {
5012
- device: "MINI",
5043
+ device: props.device || "MINI",
5013
5044
  noticeStatus: 0,
5014
5045
  receiveId: props.message.id
5015
5046
  }).then(() => {
@@ -5104,7 +5135,8 @@ var script$h = /* @__PURE__ */ defineComponent({
5104
5135
  props: {
5105
5136
  app: { type: String, required: true, default: "" },
5106
5137
  bannerStyle: { type: null, required: false, default: "" },
5107
- fixed: { type: Boolean, required: false, default: false }
5138
+ fixed: { type: Boolean, required: false, default: false },
5139
+ device: { type: String, required: false, default: "MINI" }
5108
5140
  },
5109
5141
  emits: ["detail", "close", "view", "popup", "hasBanner"],
5110
5142
  setup(__props, { emit: __emit }) {
@@ -5140,7 +5172,7 @@ var script$h = /* @__PURE__ */ defineComponent({
5140
5172
  const appkitOptions = useAppKitOptions();
5141
5173
  const $http = useHttp$1();
5142
5174
  $http.post("/cas/msg/queryNoticeMsg", {
5143
- device: "MINI",
5175
+ device: props.device || "MINI",
5144
5176
  deviceType: 2,
5145
5177
  msgType: 3,
5146
5178
  appCode: props.app || appkitOptions.app(),
@@ -5180,8 +5212,7 @@ var script$h = /* @__PURE__ */ defineComponent({
5180
5212
  stopMessageCarousel();
5181
5213
  const $http = useHttp$1();
5182
5214
  $http.post("/cas/msg/setMsgStatus", {
5183
- device: "MINI",
5184
- deviceType: 0,
5215
+ device: props.device || "MINI",
5185
5216
  noticeStatus: 1,
5186
5217
  receiveId: item.id
5187
5218
  }).then(() => {
@@ -5209,6 +5240,11 @@ var script$h = /* @__PURE__ */ defineComponent({
5209
5240
  startMessageCarousel();
5210
5241
  }, 100);
5211
5242
  const emits = __emit;
5243
+ function onPopupClose() {
5244
+ setTimeout(() => {
5245
+ popMessages.value.splice(0, 1);
5246
+ }, 100);
5247
+ }
5212
5248
  return (_ctx, _cache) => {
5213
5249
  return openBlock(), createElementBlock(
5214
5250
  Fragment,
@@ -5236,7 +5272,7 @@ var script$h = /* @__PURE__ */ defineComponent({
5236
5272
  onClose: ($event) => unref(onClose)(item, key)
5237
5273
  }, {
5238
5274
  default: withCtx(() => [
5239
- _cache[3] || (_cache[3] = createElementVNode(
5275
+ _cache[2] || (_cache[2] = createElementVNode(
5240
5276
  "img",
5241
5277
  {
5242
5278
  class: "notice-banner-icon",
@@ -5273,10 +5309,11 @@ var script$h = /* @__PURE__ */ defineComponent({
5273
5309
  createCommentVNode(" \u7CFB\u7EDF\u516C\u544A\u5F3A\u5236\u5F39\u6846 "),
5274
5310
  popMessages.value.length ? (openBlock(), createBlock(script$i, {
5275
5311
  key: 1,
5312
+ device: _ctx.device,
5276
5313
  message: popMessages.value[0],
5277
- onClose: _cache[1] || (_cache[1] = ($event) => popMessages.value.splice(0, 1)),
5278
- onView: _cache[2] || (_cache[2] = ($event) => onView(popMessages.value[0]))
5279
- }, null, 8, ["message"])) : createCommentVNode("v-if", true)
5314
+ onClose: onPopupClose,
5315
+ onView: _cache[1] || (_cache[1] = ($event) => onView(popMessages.value[0]))
5316
+ }, null, 8, ["device", "message"])) : createCommentVNode("v-if", true)
5280
5317
  ],
5281
5318
  64
5282
5319
  /* STABLE_FRAGMENT */
@@ -5951,6 +5988,13 @@ const vendor = {
5951
5988
  header,
5952
5989
  data: config.data
5953
5990
  }).then(({ data }) => {
5991
+ const endTime = (/* @__PURE__ */ new Date()).getTime();
5992
+ logger.info({
5993
+ send: JSON.stringify({ url: config.url, data: config.data }),
5994
+ receive: JSON.stringify(data),
5995
+ traceId: header.traceId,
5996
+ duration: endTime - startTime
5997
+ });
5954
5998
  if (data.success) {
5955
5999
  resolve({
5956
6000
  status: +data.code,
@@ -5963,13 +6007,6 @@ const vendor = {
5963
6007
  icon: "none"
5964
6008
  });
5965
6009
  }
5966
- const endTime = (/* @__PURE__ */ new Date()).getTime();
5967
- logger.info({
5968
- send: JSON.stringify({ url: config.url, data: config.data }),
5969
- receive: JSON.stringify(data),
5970
- traceId: header.traceId,
5971
- duration: endTime - startTime
5972
- });
5973
6010
  }).catch((e) => {
5974
6011
  reject(e);
5975
6012
  });
@@ -9297,4 +9334,4 @@ const AppKit = {
9297
9334
  }
9298
9335
  };
9299
9336
 
9300
- export { script$s as AccountView, script$L as AmountPicker, script$J as AppDrawer, script$I as AppVerify, script$y as BalanceCard, script$r as BalanceReminder, script$q as DateRange, script$G as DeviceVersion, script$o as ListFilter, script$4 as LoginSetting, script$h as NoticeBanner, script$g as NoticeEntry, script$e as NoticeList, script$E as OcrBusinessLicense, script$F as OcrIcon, script$K as PageHeader, script$n as PromoterCard, script$B as RechargeResult, script$D as RechargeView, script$j as SelfRegistration, script as SharePoster, script$z as TradeView, script$C as UserAgreement, script$2 as UserAuth, script$a as UserBinding, script$9 as UserBindingSuccess, script$d as UserEntry, script$6 as UserFeedback, script$5 as UserFeedbackEntry, script$7 as UserHeadCrop, script$b as UserInfo, script$3 as UserResourceEmpty, components, createHttp, AppKit as default, defaultCryptoConfig, generateUniqueId, getSdkConfig, jssdkServices, requestPayment$2 as requestPayment, requestWxH5Pay, services$1 as services, useAppKit, useCountdown, useCrypto, useEncode, useLogger, useSafeArea, useTabbar, useUpload, useValidator };
9337
+ export { script$s as AccountView, script$L as AmountPicker, script$J as AppDrawer, script$I as AppVerify, script$y as BalanceCard, script$r as BalanceReminder, script$q as DateRange, script$G as DeviceVersion, script$o as ListFilter, script$4 as LoginSetting, script$h as NoticeBanner, script$g as NoticeEntry, script$e as NoticeList, script$E as OcrBusinessLicense, script$F as OcrIcon, script$K as PageHeader, script$n as PromoterCard, script$B as RechargeResult, script$D as RechargeView, script$j as SelfRegistration, script as SharePoster, script$z as TradeView, script$C as UserAgreement, script$2 as UserAuth, script$a as UserBinding, script$9 as UserBindingSuccess, script$d as UserEntry, script$6 as UserFeedback, script$5 as UserFeedbackEntry, script$7 as UserHeadCrop, script$b as UserInfo, script$3 as UserResourceEmpty, components, createHttp, AppKit as default, defaultCryptoConfig, generateUniqueId, getSdkConfig, jssdkServices, requestPayment$2 as requestPayment, requestWxH5Pay, services$1 as services, useAppKit, useCountdown, useCrypto, useEncode, useLogger, useSafeArea, useTabbar, useUpload, useValidator, useWxAuth };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uxda/appkit",
3
- "version": "4.2.78",
3
+ "version": "4.2.80",
4
4
  "description": "小程序应用开发包",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.ts",
@@ -25,6 +25,15 @@ const vendor = {
25
25
  data: config.data,
26
26
  })
27
27
  .then(({ data }) => {
28
+ // 记录阿里日志
29
+ const endTime = new Date().getTime()
30
+ logger.info({
31
+ send: JSON.stringify({ url: config.url, data: config.data }),
32
+ receive: JSON.stringify(data),
33
+ traceId: header.traceId,
34
+ duration: endTime - startTime,
35
+ })
36
+
28
37
  if (data.success) {
29
38
  resolve({
30
39
  status: +data.code,
@@ -37,15 +46,6 @@ const vendor = {
37
46
  icon: 'none',
38
47
  })
39
48
  }
40
-
41
- // 记录阿里日志
42
- const endTime = new Date().getTime()
43
- logger.info({
44
- send: JSON.stringify({ url: config.url, data: config.data }),
45
- receive: JSON.stringify(data),
46
- traceId: header.traceId,
47
- duration: endTime - startTime,
48
- })
49
49
  })
50
50
  .catch((e: any) => {
51
51
  reject(e)
package/src/index.ts CHANGED
@@ -71,6 +71,7 @@ const AppKit = {
71
71
  appKitOptions.baseUrl = options.baseUrl
72
72
  appKitOptions[401] = options[401]
73
73
  appKitOptions.gray = options.gray
74
+
74
75
  nutComponents.forEach((component) => {
75
76
  app.use(component)
76
77
  })
@@ -25,6 +25,15 @@ const vendor = {
25
25
  data: config.data,
26
26
  })
27
27
  .then(({ data }) => {
28
+ // 记录阿里日志
29
+ const endTime = new Date().getTime()
30
+ logger.info({
31
+ send: JSON.stringify({ url: config.url, data: config.data }),
32
+ receive: JSON.stringify(data),
33
+ traceId: header.traceId,
34
+ duration: endTime - startTime,
35
+ })
36
+
28
37
  if (data.success) {
29
38
  resolve({
30
39
  status: +data.code,
@@ -37,15 +46,6 @@ const vendor = {
37
46
  icon: 'none',
38
47
  })
39
48
  }
40
-
41
- // 记录阿里日志
42
- const endTime = new Date().getTime()
43
- logger.info({
44
- send: JSON.stringify({ url: config.url, data: config.data }),
45
- receive: JSON.stringify(data),
46
- traceId: header.traceId,
47
- duration: endTime - startTime,
48
- })
49
49
  })
50
50
  .catch((e: any) => {
51
51
  reject(e)
@@ -12,7 +12,7 @@
12
12
  </div>
13
13
 
14
14
  <!-- 系统公告强制弹框 -->
15
- <NoticePopup v-if="popMessages.length" :message="popMessages[0]" @close="popMessages.splice(0, 1)"
15
+ <NoticePopup v-if="popMessages.length" :device="device" :message="popMessages[0]" @close="onPopupClose"
16
16
  @view="onView(popMessages[0])" />
17
17
  </template>
18
18
 
@@ -32,11 +32,13 @@ const props = withDefaults(
32
32
  app: string
33
33
  bannerStyle?: any
34
34
  fixed?: boolean
35
+ device?: string
35
36
  }>(),
36
37
  {
37
38
  app: '',
38
39
  bannerStyle: '',
39
40
  fixed: false,
41
+ device: 'MINI',
40
42
  }
41
43
  )
42
44
 
@@ -78,7 +80,7 @@ async function queryNoticeMsg() {
78
80
  const $http = useHttp()
79
81
  $http
80
82
  .post('/cas/msg/queryNoticeMsg', {
81
- device: 'MINI',
83
+ device: props.device || 'MINI',
82
84
  deviceType: 2,
83
85
  msgType: 3,
84
86
  appCode: props.app || appkitOptions.app(),
@@ -128,8 +130,7 @@ const onClose = debounce((item: any, index: number) => {
128
130
  const $http = useHttp()
129
131
  $http
130
132
  .post('/cas/msg/setMsgStatus', {
131
- device: 'MINI',
132
- deviceType: 0,
133
+ device: props.device || 'MINI',
133
134
  noticeStatus: 1,
134
135
  receiveId: item.id,
135
136
  })
@@ -173,6 +174,12 @@ const onTouchEnd = debounce(() => {
173
174
 
174
175
  // 父组件事件
175
176
  const emits = defineEmits(['detail', 'close', 'view', 'popup', 'hasBanner'])
177
+
178
+ function onPopupClose() {
179
+ setTimeout(() => {
180
+ popMessages.value.splice(0, 1)
181
+ }, 100);
182
+ }
176
183
  </script>
177
184
 
178
185
  <style lang="scss">
@@ -23,9 +23,11 @@ import { useHttp } from '../api'
23
23
  const props = withDefaults(
24
24
  defineProps<{
25
25
  message: any
26
+ device?: string
26
27
  }>(),
27
28
  {
28
29
  message: {},
30
+ device: 'MINI',
29
31
  }
30
32
  )
31
33
 
@@ -53,7 +55,7 @@ async function onClose() {
53
55
 
54
56
  $http
55
57
  .post('/cas/msg/setMsgStatus', {
56
- device: 'MINI',
58
+ device: props.device || 'MINI',
57
59
  noticeStatus: 0,
58
60
  receiveId: props.message.id,
59
61
  })
@@ -25,6 +25,15 @@ const vendor = {
25
25
  data: config.data,
26
26
  })
27
27
  .then(({ data }) => {
28
+ // 记录阿里日志
29
+ const endTime = new Date().getTime()
30
+ logger.info({
31
+ send: JSON.stringify({ url: config.url, data: config.data }),
32
+ receive: JSON.stringify(data),
33
+ traceId: header.traceId,
34
+ duration: endTime - startTime,
35
+ })
36
+
28
37
  if (data.success) {
29
38
  resolve({
30
39
  status: +data.code,
@@ -37,15 +46,6 @@ const vendor = {
37
46
  icon: 'none',
38
47
  })
39
48
  }
40
-
41
- // 记录阿里日志
42
- const endTime = new Date().getTime()
43
- logger.info({
44
- send: JSON.stringify({ url: config.url, data: config.data }),
45
- receive: JSON.stringify(data),
46
- traceId: header.traceId,
47
- duration: endTime - startTime,
48
- })
49
49
  })
50
50
  .catch((e: any) => {
51
51
  reject(e)
@@ -67,6 +67,7 @@ function useHttp(defaultHeader?: DefaultHeaderType) {
67
67
  cookie: `tid=${defaultHeader?.Tenant || appkitOptions.tenant()}`,
68
68
  gray: appkitOptions.gray ? appkitOptions.gray() : '0',
69
69
  }
70
+
70
71
  /**
71
72
  * 传入配置获取 Http instanse
72
73
  */
@@ -6,3 +6,4 @@ export * from './useEncode'
6
6
  export * from './useUpload'
7
7
  export * from './useCrypto'
8
8
  export * from './useLogger'
9
+ export * from './useWxAuth'
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @description: H5微信授权相关
3
+ */
4
+
5
+ import { useHttp } from '../../payment/api'
6
+
7
+ export function useWxAuth() {
8
+ /**
9
+ * 跳转微信授权页面,授权完成后,返回授权码code与state
10
+ * @param source 设备码
11
+ * @param redirectUri 重定向地址
12
+ */
13
+ function toWxAuth(source, redirectUri) {
14
+ const $http = useHttp()
15
+ $http
16
+ .get('/cas/auth/render/', {
17
+ source,
18
+ redirectUri,
19
+ })
20
+ .then((res: any) => {
21
+ location.replace(res)
22
+ })
23
+ }
24
+
25
+ /**
26
+ * 授权回调后,登录cas获取用户信息
27
+ * @param source
28
+ * @param state
29
+ */
30
+ async function toCallbackLogin({ code, state, source }, cb) {
31
+ const $http = useHttp()
32
+ const res = await $http.post(
33
+ `/cas/auth/callbackLogin/${source}`,
34
+ { code, state, source },
35
+ {
36
+ 'Content-Type': 'application/x-www-form-urlencoded',
37
+ }
38
+ )
39
+ if (res) {
40
+ cb && cb(res)
41
+ }
42
+ }
43
+
44
+ return {
45
+ toWxAuth,
46
+ toCallbackLogin,
47
+ }
48
+ }
@@ -8,6 +8,7 @@ import {
8
8
  ResponseRaw,
9
9
  Paging,
10
10
  HttpTranslate,
11
+ RequestHeaders,
11
12
  } from './types'
12
13
  /**
13
14
  * Useage:
@@ -96,11 +97,16 @@ const get: HttpInstance['get'] = <T = ResponseData>(url: string, data?: RequestD
96
97
  })
97
98
  }
98
99
 
99
- const post: HttpInstance['post'] = <T = ResponseData>(url: string, data: RequestData) => {
100
+ const post: HttpInstance['post'] = <T = ResponseData>(
101
+ url: string,
102
+ data: RequestData,
103
+ headers?: RequestHeaders
104
+ ) => {
100
105
  return request<T>({
101
106
  url,
102
107
  data,
103
108
  method: HttpMethod.post,
109
+ headers,
104
110
  })
105
111
  }
106
112
 
@@ -3,21 +3,21 @@
3
3
  * createHttp() 使用的配置
4
4
  */
5
5
  export type HttpClientConfig = {
6
- vendor?: HttpVendor,
7
- baseUrl: string,
6
+ vendor?: HttpVendor
7
+ baseUrl: string
8
8
  /**
9
9
  * 向 HTTP header 加入的数据
10
10
  * 通常含有 JWT token 以及其他参数
11
11
  */
12
- headers?: HeaderParams,
13
- paging?: Paging,
12
+ headers?: HeaderParams
13
+ paging?: Paging
14
14
  /**
15
15
  * 拦截器组
16
16
  * 请求返回异常时进行一定的操作
17
17
  */
18
- interceptors?: HttpInterceptor[],
19
- translates?: HttpTranslates,
20
- transforms?: HttpTransforms,
18
+ interceptors?: HttpInterceptor[]
19
+ translates?: HttpTranslates
20
+ transforms?: HttpTransforms
21
21
  }
22
22
 
23
23
  /**
@@ -25,7 +25,7 @@ export type HttpClientConfig = {
25
25
  * Axios/Taro.request
26
26
  */
27
27
  export type HttpVendor = {
28
- request <T = ResponseData>(config: HttpRequestConfig): Promise<ResponseRaw<T>>
28
+ request<T = ResponseData>(config: HttpRequestConfig): Promise<ResponseRaw<T>>
29
29
  }
30
30
 
31
31
  export type HttpInterceptor = (raw: ResponseRaw) => boolean
@@ -35,11 +35,11 @@ export type HttpInterceptor = (raw: ResponseRaw) => boolean
35
35
  * 沿用 Axios 的部分配置
36
36
  */
37
37
  export type HttpRequestConfig<D = RequestData> = {
38
- url: string,
39
- method?: HttpMethod,
40
- baseUrl?: string,
41
- headers?: HeaderData,
42
- data?: D,
38
+ url: string
39
+ method?: HttpMethod
40
+ baseUrl?: string
41
+ headers?: HeaderData
42
+ data?: D
43
43
  }
44
44
 
45
45
  /**
@@ -47,12 +47,14 @@ export type HttpRequestConfig<D = RequestData> = {
47
47
  */
48
48
  export type RequestData = Record<string, any>
49
49
 
50
+ export type RequestHeaders = Record<string, any>
51
+
50
52
  /**
51
53
  * 接口请求返回的标准格式
52
54
  */
53
55
  export type ResponseRaw<T = ResponseData> = {
54
- status: number,
55
- message: string,
56
+ status: number
57
+ message: string
56
58
  data: T
57
59
  }
58
60
 
@@ -63,8 +65,8 @@ export type ResponseData = Record<string, any> | any[]
63
65
 
64
66
  export type HttpInstance = {
65
67
  request<T = ResponseData>(config: HttpRequestConfig): Promise<T>
66
- get<T = ResponseData>(url: string, data?: RequestData): Promise<T>,
67
- post<T = ResponseData>(url: string, data?: RequestData): Promise<T>,
68
+ get<T = ResponseData>(url: string, data?: RequestData): Promise<T>
69
+ post<T = ResponseData>(url: string, data?: RequestData, headers?: RequestHeaders): Promise<T>
68
70
  }
69
71
 
70
72
  /**
@@ -88,7 +90,7 @@ export enum HttpMethod {
88
90
 
89
91
  export enum HttpError {
90
92
  auth = 'auth',
91
- server = 'server'
93
+ server = 'server',
92
94
  }
93
95
 
94
96
  export type HeaderData = Record<string, string>
@@ -107,9 +109,9 @@ export type HttpTransform = (data: ResponseData) => ResponseData
107
109
  * 接口设置
108
110
  */
109
111
  export type HttpEndpoint = {
110
- path: string,
111
- translate?: HttpTranslate,
112
- transform?: HttpTransform,
112
+ path: string
113
+ translate?: HttpTranslate
114
+ transform?: HttpTransform
113
115
  }
114
116
 
115
117
  /**
@@ -126,33 +128,33 @@ export type PagingParams = {
126
128
  /**
127
129
  * 页数
128
130
  */
129
- page: number,
131
+ page: number
130
132
  /**
131
133
  * 页数据条数
132
134
  */
133
- pageSize: number,
135
+ pageSize: number
134
136
  }
135
137
 
136
138
  export type PagingData = {
137
139
  /**
138
140
  * 页总数
139
141
  */
140
- totalPages: number,
142
+ totalPages: number
141
143
  }
142
144
 
143
145
  /**
144
146
  * Wrapped with Paging Data
145
147
  */
146
148
  export type WithPaging<T = ResponseData> = {
147
- [K in keyof PagingData]: PagingData[K];
149
+ [K in keyof PagingData]: PagingData[K]
148
150
  } & {
149
- data: T;
151
+ data: T
150
152
  }
151
153
 
152
154
  /**
153
155
  * 分页设置
154
156
  */
155
157
  export type Paging = {
156
- translate (params: PagingParams): any,
157
- transform (resonse: any): PagingData,
158
- }
158
+ translate(params: PagingParams): any
159
+ transform(resonse: any): PagingData
160
+ }
@@ -25,6 +25,15 @@ const vendor = {
25
25
  data: config.data,
26
26
  })
27
27
  .then(({ data }) => {
28
+ // 记录阿里日志
29
+ const endTime = new Date().getTime()
30
+ logger.info({
31
+ send: JSON.stringify({ url: config.url, data: config.data }),
32
+ receive: JSON.stringify(data),
33
+ traceId: header.traceId,
34
+ duration: endTime - startTime,
35
+ })
36
+
28
37
  if (data.success) {
29
38
  resolve({
30
39
  status: +data.code,
@@ -37,15 +46,6 @@ const vendor = {
37
46
  icon: 'none',
38
47
  })
39
48
  }
40
-
41
- // 记录阿里日志
42
- const endTime = new Date().getTime()
43
- logger.info({
44
- send: JSON.stringify({ url: config.url, data: config.data }),
45
- receive: JSON.stringify(data),
46
- traceId: header.traceId,
47
- duration: endTime - startTime,
48
- })
49
49
  })
50
50
  .catch((e: any) => {
51
51
  reject(e)