fix: get_chart_usage add undefined value check

This commit is contained in:
ulleo
2026-08-19 15:00:40 +08:00
committed by ulleo
parent d33e42004c
commit 10663cc793
+21 -19
View File
@@ -937,25 +937,27 @@ async function clickAnalysis(id?: number) {
function getRecordUsage(recordId: any) {
console.debug('getRecordUsage id: ', recordId)
nextTick(() => {
chatApi
.get_chart_usage(recordId)
.then((res) => {
const logHistory = chatApi.toChatLogHistory(res)
if (logHistory) {
currentChat.value.records.forEach((record) => {
if (record.id === recordId) {
record.duration = logHistory.duration
record.finish_time = logHistory.finish_time
record.total_tokens = logHistory.total_tokens
}
})
}
})
.catch((e) => {
console.error(e)
})
})
if (recordId) {
nextTick(() => {
chatApi
.get_chart_usage(recordId)
.then((res) => {
const logHistory = chatApi.toChatLogHistory(res)
if (logHistory) {
currentChat.value.records.forEach((record) => {
if (record.id === recordId) {
record.duration = logHistory.duration
record.finish_time = logHistory.finish_time
record.total_tokens = logHistory.total_tokens
}
})
}
})
.catch((e) => {
console.error(e)
})
})
}
}
const predictAnswerRef = ref()