mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
feat: predict data display
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user