diff --git a/pages/search/[id].vue b/pages/search/[id].vue index 004cdde89976ce5ac46fc66b871da2a5116bb7dd..034615c5a91fcc69ad5a1307a9435ca3112574c1 100644 --- a/pages/search/[id].vue +++ b/pages/search/[id].vue @@ -76,7 +76,8 @@ function initSearchItemInfo (info, records) { } function initSearchRecords (records) { data.value = records.map(item => { - let { answer, actions, question } = item + let { answer, actions, question, answer_type } = item + answer = answer_type === 'json' ? handleFormatReports(answer) : answer const historyItem = { article: answer, question, desLoading: false, searchLoading: false, ansLoading: false, showActions: true} // todo ?action为啥成了string? actions = typeof actions === 'string' ? JSON.parse(actions) : actions @@ -195,7 +196,7 @@ function handleFormatReports (content) { // todo let tableStart = '::ProseDataTable' let result = '' - // ::ProseLineChart{title='xxx' :labels='[]' :data='[]'} + // ::ProseLineChart{title='langchain-ai/langchain [2023-06-05,2024-06-04] Star Data' :labels='["2023-06-05","2023-06-12"]' :data='[43071,44946]'} content.forEach(item => { const { title, data, format } = item if (format === 'timeline') { @@ -205,7 +206,7 @@ function handleFormatReports (content) { labels.push(child.date) datas.push(child.stargazers) }) - result += `${chartStart}{title=${title} :labels=${JSON.stringify(labels)} :data=${JSON.stringify(datas)}}` + result += `${chartStart}{title='${title}' :labels='${JSON.stringify(labels)}' :data='${JSON.stringify(datas)}'}` } else if ( format === 'table' ) { result += `${tableStart}{:data=${JSON.stringify(data)}}` }