xto-fronted 0.4.78 → 0.4.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-Pg_OaPt4.js → index-CU6U2g_s.js} +1 -1
- package/dist/{index-dVHlrUjM.js → index-CriNPYL1.js} +1 -1
- package/dist/{index-DkHXkwpw.js → index-DdPlL00H.js} +1 -1
- package/dist/{index-BcEjdbz_.js → index-Ds-fNYvz.js} +1 -1
- package/dist/index-mZYorZOq.js +4128 -0
- package/dist/index.es.js +1 -1
- package/dist/index.umd.js +8 -1
- package/package.json +4 -3
- package/src/types/json-bigint.d.ts +18 -0
- package/src/utils/request.ts +18 -1
- package/dist/index-CWMpaJJ6.js +0 -3267
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xto-fronted",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.80",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "XTO 前端应用框架",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@xto/core": "^1.0.3",
|
|
41
41
|
"@xto/data": "^1.1.4",
|
|
42
42
|
"@xto/feedback": "^1.1.8",
|
|
43
|
-
"@xto/form": "^1.1.
|
|
43
|
+
"@xto/form": "^1.1.6",
|
|
44
44
|
"@xto/layout": "^1.0.7",
|
|
45
45
|
"@xto/navigation": "^1.2.6",
|
|
46
46
|
"axios": "^1.6.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@xto/core": "^1.0.3",
|
|
57
57
|
"@xto/data": "^1.1.4",
|
|
58
58
|
"@xto/feedback": "^1.1.8",
|
|
59
|
-
"@xto/form": "^1.1.
|
|
59
|
+
"@xto/form": "^1.1.6",
|
|
60
60
|
"@xto/layout": "^1.0.7",
|
|
61
61
|
"@xto/navigation": "^1.2.9",
|
|
62
62
|
"axios": "^1.6.8",
|
|
@@ -85,6 +85,7 @@
|
|
|
85
85
|
"url": "git+https://github.com/jinguchu/xto-ui.git"
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
+
"json-bigint": "^1.0.0",
|
|
88
89
|
"xto-fronted": "0.4.71"
|
|
89
90
|
}
|
|
90
91
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare module 'json-bigint' {
|
|
2
|
+
interface JSONBigintOptions {
|
|
3
|
+
storeAsString?: boolean
|
|
4
|
+
alwaysParseAsBig?: boolean
|
|
5
|
+
useNativeBigInt?: boolean
|
|
6
|
+
protoAction?: 'error' | 'ignore' | 'preserve'
|
|
7
|
+
constructorAction?: 'error' | 'ignore' | 'preserve'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface JSONBigint {
|
|
11
|
+
parse(text: string): any
|
|
12
|
+
stringify(value: any, replacer?: any, space?: string | number): string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function JSONBig(options?: JSONBigintOptions): JSONBigint
|
|
16
|
+
|
|
17
|
+
export = JSONBig
|
|
18
|
+
}
|
package/src/utils/request.ts
CHANGED
|
@@ -5,6 +5,10 @@
|
|
|
5
5
|
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from 'axios'
|
|
6
6
|
import { getToken, getTokenType, clearToken } from './auth'
|
|
7
7
|
import { Message } from '@xto/feedback'
|
|
8
|
+
import JSONBig from 'json-bigint'
|
|
9
|
+
|
|
10
|
+
// 配置 json-bigint 将大整数转为字符串,避免 JavaScript Number 精度丢失
|
|
11
|
+
const JSONBigString = JSONBig({ storeAsString: true })
|
|
8
12
|
|
|
9
13
|
// 响应数据接口(Euler 框架 Result 格式)
|
|
10
14
|
export interface ApiResponse<T = unknown> {
|
|
@@ -32,7 +36,20 @@ const createRequest = (): AxiosInstance => {
|
|
|
32
36
|
timeout: 30000,
|
|
33
37
|
headers: {
|
|
34
38
|
'Content-Type': 'application/json'
|
|
35
|
-
}
|
|
39
|
+
},
|
|
40
|
+
// 使用 json-bigint 解析响应数据,避免大整数精度丢失
|
|
41
|
+
transformResponse: [
|
|
42
|
+
(data) => {
|
|
43
|
+
if (typeof data === 'string') {
|
|
44
|
+
try {
|
|
45
|
+
return JSONBigString.parse(data)
|
|
46
|
+
} catch (e) {
|
|
47
|
+
return data
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return data
|
|
51
|
+
}
|
|
52
|
+
]
|
|
36
53
|
})
|
|
37
54
|
|
|
38
55
|
// 请求拦截器
|