@lark-apaas/client-toolkit 1.0.1 → 1.0.3
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/lib/components/AppContainer/PageHoc.js +3 -0
- package/lib/components/AppContainer/utils/childApi.js +13 -1
- package/lib/components/ErrorRender/index.js +7 -1
- package/lib/types/iframe-events.d.ts +1 -0
- package/lib/utils/axiosConfig.d.ts +5 -0
- package/lib/utils/axiosConfig.js +64 -0
- package/package.json +2 -3
|
@@ -14,7 +14,19 @@ async function getRoutes() {
|
|
|
14
14
|
}
|
|
15
15
|
return routes;
|
|
16
16
|
}
|
|
17
|
+
async function getSourceMap() {
|
|
18
|
+
let sourceMapContent = '';
|
|
19
|
+
try {
|
|
20
|
+
const basePath = normalizeBasePath(process.env.CLIENT_BASE_PATH);
|
|
21
|
+
const res = await fetch(`${basePath}/main.js.map`);
|
|
22
|
+
sourceMapContent = await res.text();
|
|
23
|
+
} catch (e) {
|
|
24
|
+
console.warn('get main.js.map error', e);
|
|
25
|
+
}
|
|
26
|
+
return sourceMapContent;
|
|
27
|
+
}
|
|
17
28
|
const childApi = {
|
|
18
|
-
getRoutes
|
|
29
|
+
getRoutes,
|
|
30
|
+
getSourceMap
|
|
19
31
|
};
|
|
20
32
|
export { childApi };
|
|
@@ -9,13 +9,19 @@ const RenderError = (props)=>{
|
|
|
9
9
|
const location = useLocation();
|
|
10
10
|
const onClickCopy = useCallback(()=>{
|
|
11
11
|
const { message, stack } = error ?? {};
|
|
12
|
-
let result =
|
|
12
|
+
let result = '';
|
|
13
13
|
if (message && stack) {
|
|
14
14
|
const wrapIndex = stack.indexOf('\n');
|
|
15
15
|
const extraMsg = -1 !== wrapIndex ? stack.slice(0, wrapIndex) : stack;
|
|
16
16
|
result = `${message}
|
|
17
17
|
${extraMsg}`;
|
|
18
18
|
}
|
|
19
|
+
if (!result) try {
|
|
20
|
+
result = JSON.stringify(error);
|
|
21
|
+
} catch (e) {
|
|
22
|
+
console.error('复制到剪切板失败:', error);
|
|
23
|
+
result = 'unknown error';
|
|
24
|
+
}
|
|
19
25
|
copyToClipboard(result);
|
|
20
26
|
}, [
|
|
21
27
|
error
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { logger } from "../apis/logger.js";
|
|
3
|
+
function initAxiosConfig(axiosInstance) {
|
|
4
|
+
if (!axiosInstance) axiosInstance = axios;
|
|
5
|
+
axiosInstance.defaults.timeout = 10000;
|
|
6
|
+
axiosInstance.interceptors.request.use((config)=>{
|
|
7
|
+
config._startTime = Date.now();
|
|
8
|
+
const csrfToken = window.csrfToken;
|
|
9
|
+
if (csrfToken) config.headers['X-Suda-Csrf-Token'] = csrfToken;
|
|
10
|
+
logger.info({
|
|
11
|
+
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
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return config;
|
|
23
|
+
}, (error)=>{
|
|
24
|
+
logger.error({
|
|
25
|
+
type: 'HTTP Request',
|
|
26
|
+
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
|
+
stack: error.stack
|
|
37
|
+
});
|
|
38
|
+
return Promise.reject(error);
|
|
39
|
+
});
|
|
40
|
+
axiosInstance.interceptors.response.use((response)=>{
|
|
41
|
+
logger.info({
|
|
42
|
+
type: 'HTTP Response',
|
|
43
|
+
url: response.config.url,
|
|
44
|
+
method: response.config.method?.toUpperCase(),
|
|
45
|
+
status: response.status,
|
|
46
|
+
statusText: response.statusText,
|
|
47
|
+
responseTime: Date.now() - response.config._startTime
|
|
48
|
+
});
|
|
49
|
+
return response;
|
|
50
|
+
}, (error)=>{
|
|
51
|
+
logger.error({
|
|
52
|
+
type: 'HTTP Response',
|
|
53
|
+
url: error.config?.url,
|
|
54
|
+
method: error.config?.method?.toUpperCase(),
|
|
55
|
+
status: error.response?.status,
|
|
56
|
+
statusText: error.response?.statusText,
|
|
57
|
+
message: error.message,
|
|
58
|
+
responseData: error.response?.data,
|
|
59
|
+
responseTime: Date.now() - error.config._startTime
|
|
60
|
+
});
|
|
61
|
+
return Promise.reject(error);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
export { initAxiosConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/client-toolkit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"types": "./lib/index.d.ts",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -70,7 +70,6 @@
|
|
|
70
70
|
"test": "echo 0",
|
|
71
71
|
"lint": "eslint src --ext .js,.jsx,.ts,.tsx",
|
|
72
72
|
"lint:fix": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
|
|
73
|
-
"postinstall": "yes | npx shadcn@latest add --all -o -y -c \"$INIT_CWD\"",
|
|
74
73
|
"prepublishOnly": "npm run build && node scripts/replace-workspace-alias.js"
|
|
75
74
|
},
|
|
76
75
|
"dependencies": {
|
|
@@ -113,7 +112,7 @@
|
|
|
113
112
|
"antd": "^5.26.6",
|
|
114
113
|
"eslint": "^8.57.0",
|
|
115
114
|
"jsdom": "^26.1.0",
|
|
116
|
-
"lucide-react": "npm:@lark-apaas/lucide-react@1.0.
|
|
115
|
+
"lucide-react": "npm:@lark-apaas/lucide-react@1.0.2",
|
|
117
116
|
"react": "^18.3.1",
|
|
118
117
|
"react-dom": "^18.3.1",
|
|
119
118
|
"react-router-dom": "^6.26.2",
|