@lark-apaas/client-toolkit 1.1.16 → 1.1.17
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.
|
@@ -2,15 +2,21 @@ import { Fragment, jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect } from "react";
|
|
3
3
|
import { snapdom } from "@zumer/snapdom";
|
|
4
4
|
import { submitPostMessage } from "../../utils/postMessage.js";
|
|
5
|
+
import { clearNetworkIdle, networkIdleCallback } from "network-idle";
|
|
6
|
+
import { normalizeBasePath } from "../../utils/utils.js";
|
|
5
7
|
function PageHoc(props) {
|
|
6
8
|
const { children } = props;
|
|
7
9
|
useEffect(()=>{
|
|
8
10
|
if ('production' !== process.env.NODE_ENV) {
|
|
9
|
-
const
|
|
11
|
+
const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
|
|
12
|
+
const id = networkIdleCallback(()=>{
|
|
13
|
+
const width = document.body.scrollWidth;
|
|
14
|
+
const height = document.body.scrollHeight;
|
|
10
15
|
snapdom(document.body, {
|
|
11
16
|
format: 'png',
|
|
12
|
-
width
|
|
13
|
-
height
|
|
17
|
+
width,
|
|
18
|
+
height,
|
|
19
|
+
fallbackURL: ({ src })=>`${basePath}/dev/snapdom-proxy?url=${encodeURIComponent(src)}`,
|
|
14
20
|
exclude: [
|
|
15
21
|
'#lucide-react-svg'
|
|
16
22
|
],
|
|
@@ -22,8 +28,8 @@ function PageHoc(props) {
|
|
|
22
28
|
data: imgEle.src
|
|
23
29
|
});
|
|
24
30
|
}).catch(()=>{});
|
|
25
|
-
},
|
|
26
|
-
return ()=>
|
|
31
|
+
}, 2000);
|
|
32
|
+
return ()=>clearNetworkIdle(id);
|
|
27
33
|
}
|
|
28
34
|
}, []);
|
|
29
35
|
return /*#__PURE__*/ jsx(Fragment, {
|
|
@@ -61,6 +61,21 @@ function processDevServerLog(log) {
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
+
function listenHmrApplyFailed() {
|
|
65
|
+
const hot = import.meta.webpackHot || module.hot;
|
|
66
|
+
if (hot) hot.addStatusHandler((status)=>{
|
|
67
|
+
if ('fail' === status || 'abort' === status) {
|
|
68
|
+
console.warn('hmr apply failed', status);
|
|
69
|
+
submitSlardarEvent({
|
|
70
|
+
name: 'sandbox-devServer',
|
|
71
|
+
categories: {
|
|
72
|
+
type: 'hmr-apply-failed',
|
|
73
|
+
status
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
64
79
|
function interceptErrors() {
|
|
65
80
|
window.addEventListener('error', (event)=>{
|
|
66
81
|
logger.error(event.error);
|
|
@@ -68,6 +83,7 @@ function interceptErrors() {
|
|
|
68
83
|
window.addEventListener('unhandledrejection', (event)=>{
|
|
69
84
|
logger.error(event.reason);
|
|
70
85
|
});
|
|
86
|
+
listenHmrApplyFailed();
|
|
71
87
|
const PROXY_CONSOLE_METHOD = [
|
|
72
88
|
'log',
|
|
73
89
|
'info',
|
package/lib/utils/axiosConfig.js
CHANGED
|
@@ -15,9 +15,22 @@ async function logResponse(ok, response) {
|
|
|
15
15
|
'ms'
|
|
16
16
|
];
|
|
17
17
|
const logTraceID = response.headers['x-log-trace-id'];
|
|
18
|
+
const queryParams = {};
|
|
19
|
+
const url = response.config.url || '';
|
|
20
|
+
const queryString = url.split('?')[1];
|
|
21
|
+
if (queryString) {
|
|
22
|
+
const urlParams = new URLSearchParams(queryString);
|
|
23
|
+
urlParams.forEach((value, key)=>{
|
|
24
|
+
queryParams[key] = value;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (response.config.params) Object.assign(queryParams, response.config.params);
|
|
18
28
|
const args = [
|
|
19
29
|
{
|
|
20
30
|
'请求参数:': response.config.data,
|
|
31
|
+
...Object.keys(queryParams).length > 0 && {
|
|
32
|
+
'查询参数:': queryParams
|
|
33
|
+
},
|
|
21
34
|
'返回数据:': response.data,
|
|
22
35
|
'请求摘要:': {
|
|
23
36
|
TraceID: logTraceID,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/client-toolkit",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.17",
|
|
4
4
|
"types": "./lib/index.d.ts",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -88,6 +88,7 @@
|
|
|
88
88
|
"dayjs": "^1.11.13",
|
|
89
89
|
"echarts": "^6.0.0",
|
|
90
90
|
"lodash": "^4.17.21",
|
|
91
|
+
"network-idle": "^0.2.0",
|
|
91
92
|
"penpal": "^6.2.2",
|
|
92
93
|
"sockjs-client": "^1.6.1",
|
|
93
94
|
"sonner": "~2.0.0",
|
|
@@ -123,7 +124,7 @@
|
|
|
123
124
|
"antd": "^5.26.6",
|
|
124
125
|
"eslint": "^8.57.0",
|
|
125
126
|
"jsdom": "^26.1.0",
|
|
126
|
-
"lucide-react": "
|
|
127
|
+
"lucide-react": "^0.554.0",
|
|
127
128
|
"react": "^18.3.1",
|
|
128
129
|
"react-dom": "^18.3.1",
|
|
129
130
|
"react-router-dom": "^6.26.2",
|