@lark-apaas/client-toolkit 1.0.3 → 1.0.4

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # @lark-apaas/client-core
1
+ # @lark-apaas/client-toolkit
2
2
 
3
3
  ## 项目架构设计
4
4
 
@@ -9,7 +9,9 @@ import { PageHoc } from "./PageHoc.js";
9
9
  import { ThemeProvider, findValueByPixel, generateTailwindRadiusToken, themeColorTokenMap, themeMetaOptions } from "../theme/index.js";
10
10
  import { registerDayjsPlugins } from "./dayjsPlugins.js";
11
11
  import "../../index.css";
12
+ import { initAxiosConfig } from "../../utils/axiosConfig.js";
12
13
  registerDayjsPlugins();
14
+ initAxiosConfig();
13
15
  const isMiaodaPreview = window.IS_MIAODA_PREVIEW;
14
16
  const App = (props)=>{
15
17
  const { themeMeta = {} } = props;
@@ -1,4 +1,4 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { useCallback, useEffect } from "react";
3
3
  import { useLocation } from "react-router-dom";
4
4
  import { Button } from "antd";
@@ -56,27 +56,31 @@ const RenderError = (props)=>{
56
56
  }),
57
57
  /*#__PURE__*/ jsx("p", {
58
58
  className: "text-l/[22px] text-[#1F2329] font-medium mb-2",
59
- children: "哎呀,写错代码了"
59
+ children: 'production' !== process.env.NODE_ENV ? '哎呀,写错代码了' : '哎呀,出错了'
60
60
  }),
61
- /*#__PURE__*/ jsx("p", {
62
- className: "text-sm/[22px] text-[#646A73] font-normal mb-2",
63
- children: "可复制错误信息,或告诉妙搭进行修复"
64
- }),
65
- /*#__PURE__*/ jsxs("div", {
66
- className: "flex space-x-4",
61
+ 'production' !== process.env.NODE_ENV ? /*#__PURE__*/ jsxs(Fragment, {
67
62
  children: [
68
- /*#__PURE__*/ jsx(Button, {
69
- className: "bg-white text-gray-600 font-[400] border rounded-[6px] shadow-xs hover:bg-gray-100 active:bg-gray-200 focus:outline-hidden h-[32px] border-[#D0D3D6]",
70
- onClick: onClickCopy,
71
- children: "复制错误信息"
63
+ /*#__PURE__*/ jsx("p", {
64
+ className: "text-sm/[22px] text-[#646A73] font-normal mb-2",
65
+ children: "可复制错误信息,或告诉妙搭进行修复"
72
66
  }),
73
- /*#__PURE__*/ jsx(Button, {
74
- className: "h-[32px] text-sm font-medium text-white bg-blue-600 border border-transparent rounded-[6px] shadow-xs hover:bg-blue-600 active:bg-blue-700 focus:outline-hidden ",
75
- onClick: onClickRepair,
76
- children: "告诉妙搭修复"
67
+ /*#__PURE__*/ jsxs("div", {
68
+ className: "flex space-x-4",
69
+ children: [
70
+ /*#__PURE__*/ jsx(Button, {
71
+ className: "bg-white text-gray-600 font-[400] border rounded-[6px] shadow-xs hover:bg-gray-100 active:bg-gray-200 focus:outline-hidden h-[32px] border-[#D0D3D6]",
72
+ onClick: onClickCopy,
73
+ children: "复制错误信息"
74
+ }),
75
+ /*#__PURE__*/ jsx(Button, {
76
+ className: "h-[32px] text-sm font-medium text-white bg-blue-600 border border-transparent rounded-[6px] shadow-xs hover:bg-blue-600 active:bg-blue-700 focus:outline-hidden ",
77
+ onClick: onClickRepair,
78
+ children: "告诉妙搭修复"
79
+ })
80
+ ]
77
81
  })
78
82
  ]
79
- })
83
+ }) : null
80
84
  ]
81
85
  })
82
86
  });
@@ -1,5 +1,18 @@
1
1
  import axios from "axios";
2
2
  import { logger } from "../apis/logger.js";
3
+ function getRequestLogInfo(config) {
4
+ return {
5
+ url: config?.url,
6
+ method: config?.method?.toUpperCase(),
7
+ params: config?.params,
8
+ data: config?.data,
9
+ headers: {
10
+ ...config?.headers,
11
+ 'X-Suda-Csrf-Token': config?.headers['X-Suda-Csrf-Token'] ? '[REDACTED]' : void 0,
12
+ Authorization: config?.headers.Authorization ? '[REDACTED]' : void 0
13
+ }
14
+ };
15
+ }
3
16
  function initAxiosConfig(axiosInstance) {
4
17
  if (!axiosInstance) axiosInstance = axios;
5
18
  axiosInstance.defaults.timeout = 10000;
@@ -9,30 +22,14 @@ function initAxiosConfig(axiosInstance) {
9
22
  if (csrfToken) config.headers['X-Suda-Csrf-Token'] = csrfToken;
10
23
  logger.info({
11
24
  type: 'HTTP Request',
12
- url: config.url,
13
- method: config.method?.toUpperCase(),
14
- params: config.params,
15
- data: config.data,
16
- headers: {
17
- ...config.headers,
18
- 'X-Suda-Csrf-Token': config.headers['X-Suda-Csrf-Token'] ? '[REDACTED]' : void 0,
19
- Authorization: config.headers.Authorization ? '[REDACTED]' : void 0
20
- }
25
+ ...getRequestLogInfo(config)
21
26
  });
22
27
  return config;
23
28
  }, (error)=>{
24
29
  logger.error({
25
30
  type: 'HTTP Request',
31
+ ...getRequestLogInfo(error.config),
26
32
  message: error.message,
27
- url: error.config?.url,
28
- method: error.config?.method?.toUpperCase(),
29
- params: error.config?.params,
30
- data: error.config?.data,
31
- headers: {
32
- ...error.config?.headers,
33
- 'X-Suda-Csrf-Token': error.config?.headers['X-Suda-Csrf-Token'] ? '[REDACTED]' : void 0,
34
- Authorization: error.config?.headers.Authorization ? '[REDACTED]' : void 0
35
- },
36
33
  stack: error.stack
37
34
  });
38
35
  return Promise.reject(error);
@@ -40,18 +37,17 @@ function initAxiosConfig(axiosInstance) {
40
37
  axiosInstance.interceptors.response.use((response)=>{
41
38
  logger.info({
42
39
  type: 'HTTP Response',
43
- url: response.config.url,
44
- method: response.config.method?.toUpperCase(),
40
+ ...getRequestLogInfo(response.config),
45
41
  status: response.status,
46
42
  statusText: response.statusText,
43
+ responseData: response.data,
47
44
  responseTime: Date.now() - response.config._startTime
48
45
  });
49
46
  return response;
50
47
  }, (error)=>{
51
48
  logger.error({
52
49
  type: 'HTTP Response',
53
- url: error.config?.url,
54
- method: error.config?.method?.toUpperCase(),
50
+ ...getRequestLogInfo(error.config),
55
51
  status: error.response?.status,
56
52
  statusText: error.response?.statusText,
57
53
  message: error.message,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/client-toolkit",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "types": "./lib/index.d.ts",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -78,6 +78,7 @@
78
78
  "@data-loom/js": "0.3.1",
79
79
  "@lark-apaas/miaoda-inspector": "^1.0.0",
80
80
  "@zumer/snapdom": "^1.9.14",
81
+ "axios": "^1.12.2",
81
82
  "clsx": "~2.0.1",
82
83
  "dayjs": "^1.11.13",
83
84
  "echarts": "^6.0.0",