mirror of
https://gitee.com/dromara/go-view.git
synced 2026-04-23 00:00:12 +08:00
fix: 解决过滤器的错误处理
This commit is contained in:
+2
-7
@@ -72,7 +72,7 @@
|
||||
</div>
|
||||
</n-space>
|
||||
<n-card size="small">
|
||||
<n-code :code="filterRes(getSource)" language="json"></n-code>
|
||||
<n-code :code="filterRes(source)" language="json"></n-code>
|
||||
</n-card>
|
||||
</n-space>
|
||||
</n-timeline-item>
|
||||
@@ -126,11 +126,6 @@ const isCharts = computed(() => {
|
||||
return targetData.value.chartConfig.package === PackagesCategoryEnum.CHARTS
|
||||
})
|
||||
|
||||
// 获取数据
|
||||
const getSource = computed(() => {
|
||||
return JSON.stringify(source.value)
|
||||
})
|
||||
|
||||
// 处理映射列表状态结果
|
||||
const matchingHandle = (mapping: string) => {
|
||||
let res = DataResultEnum.SUCCESS
|
||||
@@ -176,7 +171,7 @@ const filterRes = (data: any) => {
|
||||
const res = fn(cloneDeep(data))
|
||||
return toString(res)
|
||||
}
|
||||
return data
|
||||
return toString(cloneDeep(data))
|
||||
} catch (error) {
|
||||
return '过滤函数错误'
|
||||
}
|
||||
|
||||
+3
-4
@@ -68,13 +68,13 @@
|
||||
<div class="editor-data-show">
|
||||
<n-space>
|
||||
<n-text depth="3">目标数据:</n-text>
|
||||
<n-code :code="toString(sourceData)" language="typescript" :word-wrap="true"></n-code>
|
||||
<n-code :code="toString(sourceData)" language="json" :word-wrap="true"></n-code>
|
||||
</n-space>
|
||||
</div>
|
||||
<div class="editor-data-show">
|
||||
<n-space>
|
||||
<n-text depth="3">过滤器结果:</n-text>
|
||||
<n-code :code="filterRes" language="typescript" :word-wrap="true"></n-code>
|
||||
<n-code :code="filterRes" language="json" :word-wrap="true"></n-code>
|
||||
</n-space>
|
||||
</div>
|
||||
</n-space>
|
||||
@@ -140,7 +140,6 @@ const fetchTargetData = async () => {
|
||||
const res = await http(requestHttpType)(completePath || '', {})
|
||||
if (res.status === ResultEnum.SUCCESS) {
|
||||
sourceData.value = res.data
|
||||
console.log(sourceData.value)
|
||||
return
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -154,7 +153,7 @@ const filterRes = computed(() => {
|
||||
const fn = new Function('data', filter.value)
|
||||
const res = fn(cloneDeep(sourceData.value))
|
||||
errorFlag.value = false
|
||||
return JSON.stringify(res)
|
||||
return toString(res)
|
||||
} catch (error) {
|
||||
errorFlag.value = true
|
||||
return '过滤函数错误'
|
||||
|
||||
Reference in New Issue
Block a user