新增json-bigint库,防止后端返回id数过大导致精度丢失
This commit is contained in:
parent
5abfccd598
commit
b37d26ad62
@ -46,6 +46,7 @@
|
|||||||
"js-beautify": "^1.10.2",
|
"js-beautify": "^1.10.2",
|
||||||
"js-cookie": "2.2.0",
|
"js-cookie": "2.2.0",
|
||||||
"jsencrypt": "^3.0.0-rc.1",
|
"jsencrypt": "^3.0.0-rc.1",
|
||||||
|
"json-bigint": "^1.0.0",
|
||||||
"jszip": "^3.7.1",
|
"jszip": "^3.7.1",
|
||||||
"mavon-editor": "^2.9.1",
|
"mavon-editor": "^2.9.1",
|
||||||
"normalize.css": "7.0.0",
|
"normalize.css": "7.0.0",
|
||||||
|
@ -5,11 +5,21 @@ import store from '../store'
|
|||||||
import { getToken } from '@/utils/auth'
|
import { getToken } from '@/utils/auth'
|
||||||
import Config from '@/settings'
|
import Config from '@/settings'
|
||||||
import Cookies from 'js-cookie'
|
import Cookies from 'js-cookie'
|
||||||
|
import JSONbig from 'json-bigint'
|
||||||
|
|
||||||
// 创建axios实例
|
// 创建axios实例
|
||||||
const service = axios.create({
|
const service = axios.create({
|
||||||
baseURL: process.env.NODE_ENV === 'production' ? process.env.VUE_APP_BASE_API : '/', // api 的 base_url
|
baseURL: process.env.NODE_ENV === 'production' ? process.env.VUE_APP_BASE_API : '/', // api 的 base_url
|
||||||
timeout: Config.timeout // 请求超时时间
|
timeout: Config.timeout, // 请求超时时间
|
||||||
|
transformResponse: [function(data) {
|
||||||
|
try {
|
||||||
|
// 使用json-bigint处理大数字
|
||||||
|
return JSONbig.parse(data)
|
||||||
|
} catch (err) {
|
||||||
|
// 如果转换失败,返回原始数据
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
}]
|
||||||
})
|
})
|
||||||
|
|
||||||
// request拦截器
|
// request拦截器
|
||||||
@ -26,6 +36,7 @@ service.interceptors.request.use(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
// response 拦截器
|
// response 拦截器
|
||||||
service.interceptors.response.use(
|
service.interceptors.response.use(
|
||||||
response => {
|
response => {
|
||||||
|
Loading…
Reference in New Issue
Block a user