feat: predict data display

This commit is contained in:
ulleo
2025-06-24 14:15:01 +08:00
parent 2c824d4765
commit ab2cd1d594
@@ -3,6 +3,7 @@ import type { ChatMessage } from '@/api/chat.ts'
import { computed, watch, ref } from 'vue'
import type { ChartTypes } from '@/views/chat/component/BaseChart.ts'
import DisplayChartBlock from '@/views/chat/component/DisplayChartBlock.vue'
import { concat } from 'lodash-es'
const props = defineProps<{
id?: number | string
@@ -11,7 +12,18 @@ const props = defineProps<{
data: string
}>()
const dataObject = computed<{
fields: Array<string>
data: Array<{ [key: string]: any }>
}>(() => {
if (props.message?.record?.data) {
return JSON.parse(props.message.record.data)
}
return {}
})
const _data = computed(() => {
let _list = []
if (
props.data &&
props.data.length > 0 &&
@@ -19,13 +31,21 @@ const _data = computed(() => {
props.data.trim().endsWith(']')
) {
try {
return JSON.parse(props.data)
_list = JSON.parse(props.data)
} catch (e) {
console.error(e)
}
}
return []
if (_list.length == 0) {
return _list
}
if (dataObject.value.data && dataObject.value.data.length > 0) {
return concat(dataObject.value.data, _list)
}
return _list
})
const blockRef = ref()