fix(接口测试): 修复推荐提取数字显示精确度错误问题
--bug=1009465 --user=赵勇 [github#9090]JSONPath提取器数据精度丢失 https://www.tapd.cn/55049933/s/1090126
This commit is contained in:
parent
09a4129dd6
commit
9d085402f1
|
@ -125,6 +125,7 @@ export default {
|
||||||
this.fullTreeNodes = [];
|
this.fullTreeNodes = [];
|
||||||
this.failsTreeNodes = [];
|
this.failsTreeNodes = [];
|
||||||
this.isRequestResult = false;
|
this.isRequestResult = false;
|
||||||
|
this.activeName = "total";
|
||||||
},
|
},
|
||||||
handleClick(tab, event) {
|
handleClick(tab, event) {
|
||||||
this.isRequestResult = false;
|
this.isRequestResult = false;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<ms-drawer class="json-path-picker" :visible="visible" :size="30" @close="close" direction="right" v-clickoutside="close">
|
<ms-drawer class="json-path-picker" :visible="visible" :size="30" @close="close" direction="right" v-clickoutside="close">
|
||||||
<template v-slot:header>
|
<template v-slot:header>
|
||||||
<ms-instructions-icon :content="tip"/>
|
<ms-instructions-icon :content="tip"/>
|
||||||
{{tip}}
|
{{ tip }}
|
||||||
</template>
|
</template>
|
||||||
<jsonpath-picker :code="data" v-on:path="pathChangeHandler" ref="jsonpathPicker"/>
|
<jsonpath-picker :code="data" v-on:path="pathChangeHandler" ref="jsonpathPicker"/>
|
||||||
</ms-drawer>
|
</ms-drawer>
|
||||||
|
@ -16,8 +16,8 @@ let dotReplace = "#DOT_MASK#";
|
||||||
|
|
||||||
const clickoutside = {
|
const clickoutside = {
|
||||||
// 初始化指令
|
// 初始化指令
|
||||||
bind (el, binding, vnode) {
|
bind(el, binding, vnode) {
|
||||||
function documentHandler (e) {
|
function documentHandler(e) {
|
||||||
// 这里判断点击的元素是否是本身,是本身,则返回
|
// 这里判断点击的元素是否是本身,是本身,则返回
|
||||||
if (el.contains(e.target)) {
|
if (el.contains(e.target)) {
|
||||||
return false
|
return false
|
||||||
|
@ -28,12 +28,14 @@ const clickoutside = {
|
||||||
binding.value(e)
|
binding.value(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 给当前元素绑定个私有变量,方便在unbind中可以解除事件监听
|
// 给当前元素绑定个私有变量,方便在unbind中可以解除事件监听
|
||||||
el.__vueClickOutside__ = documentHandler
|
el.__vueClickOutside__ = documentHandler
|
||||||
document.addEventListener('click', documentHandler)
|
document.addEventListener('click', documentHandler)
|
||||||
},
|
},
|
||||||
update () { },
|
update() {
|
||||||
unbind (el, binding) {
|
},
|
||||||
|
unbind(el, binding) {
|
||||||
// 解除事件监听
|
// 解除事件监听
|
||||||
document.removeEventListener('click', el.__vueClickOutside__)
|
document.removeEventListener('click', el.__vueClickOutside__)
|
||||||
delete el.__vueClickOutside__
|
delete el.__vueClickOutside__
|
||||||
|
@ -43,7 +45,7 @@ const clickoutside = {
|
||||||
export default {
|
export default {
|
||||||
name: "MsApiJsonpathSuggest",
|
name: "MsApiJsonpathSuggest",
|
||||||
components: {MsInstructionsIcon, MsDrawer},
|
components: {MsInstructionsIcon, MsDrawer},
|
||||||
directives: { clickoutside },
|
directives: {clickoutside},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
visible: false,
|
visible: false,
|
||||||
|
@ -67,9 +69,8 @@ export default {
|
||||||
this.data = {};
|
this.data = {};
|
||||||
try {
|
try {
|
||||||
// 解决精度丢失问题
|
// 解决精度丢失问题
|
||||||
// let stringedJSON = objStr.replace(/:\s*([-+Ee0-9.]+)/g, ': "$1"');
|
let JSONBig = require('json-bigint')({"storeAsString": true});
|
||||||
// 一些情况会解析失败,先注释掉
|
let param = JSON.parse(JSON.stringify(JSONBig.parse(objStr)));
|
||||||
let param = JSON.parse(objStr);
|
|
||||||
if (param instanceof Array) {
|
if (param instanceof Array) {
|
||||||
this.$warning('不支持解析JSON数组');
|
this.$warning('不支持解析JSON数组');
|
||||||
return;
|
return;
|
||||||
|
@ -152,23 +153,23 @@ export default {
|
||||||
return this.getParamValue(childObj, index, params);
|
return this.getParamValue(childObj, index, params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
||||||
.json-path-picker {
|
.json-path-picker {
|
||||||
padding: 10px 13px;
|
padding: 10px 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.json-path-picker >>> .json-tree {
|
.json-path-picker >>> .json-tree {
|
||||||
margin-top: 0px;
|
margin-top: 0px;
|
||||||
margin-left: 6px;
|
margin-left: 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/deep/ .el-icon-close:hover {
|
/deep/ .el-icon-close:hover {
|
||||||
font-size: 30px;
|
font-size: 30px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue