fix: json-bigint parse used in vxeTable (#6271)

* 修复vxeTable不能加载json-bigint解析的数据的问题
pull/115/head
Netfan 2025-05-24 13:01:58 +08:00 committed by GitHub
parent af186f878d
commit e5c937396d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import {
RequestClient,
} from '@vben/request';
import { useAccessStore } from '@vben/stores';
import { cloneDeep } from '@vben/utils';
import { message } from 'ant-design-vue';
import JSONBigInt from 'json-bigint';
@ -29,7 +30,9 @@ function createRequestClient(baseURL: string, options?: RequestClientOptions) {
transformResponse: (data: any, header: AxiosResponseHeaders) => {
// storeAsString指示将BigInt存储为字符串设为false则会存储为内置的BigInt类型
return header.getContentType()?.toString().includes('application/json')
? JSONBigInt({ storeAsString: true }).parse(data)
? cloneDeep(
JSONBigInt({ storeAsString: true, strict: true }).parse(data),
)
: data;
},
});