feat: 添加mock数据
This commit is contained in:
@@ -26,14 +26,14 @@
|
||||
* 输出格式:
|
||||
* {
|
||||
* segments: [
|
||||
* { text: "核心结论:...", citationId: 1 }
|
||||
* { text: "国内领先的IT解决方案提供商", citationId: 1 } // 优先使用 query_part
|
||||
* ],
|
||||
* citations: {
|
||||
* 1: {
|
||||
* author: "陈彤",
|
||||
* report_title: "深度布局...",
|
||||
* declare_date: "2025-04-17",
|
||||
* sentences: "核心结论:..."
|
||||
* sentences: "核心结论:..." // sentences 显示在弹窗中
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
@@ -55,9 +55,9 @@ export const processCitationData = (rawData) => {
|
||||
|
||||
// 处理每个引用数据项
|
||||
rawData.data.forEach((item, index) => {
|
||||
// 验证必需字段
|
||||
if (!item.sentences) {
|
||||
console.warn(`citationUtils: Missing 'sentences' field in item ${index}`);
|
||||
// 验证必需字段(至少需要 query_part 或 sentences 之一)
|
||||
if (!item.query_part && !item.sentences) {
|
||||
console.warn(`citationUtils: Missing both 'query_part' and 'sentences' fields in item ${index}`);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ export const processCitationData = (rawData) => {
|
||||
|
||||
// 构建文本片段
|
||||
segments.push({
|
||||
text: item.sentences,
|
||||
text: item.query_part || item.sentences, // 优先使用 query_part,降级到 sentences
|
||||
citationId: citationId
|
||||
});
|
||||
|
||||
@@ -126,6 +126,6 @@ export const isValidCitationData = (data) => {
|
||||
if (!data.data || !Array.isArray(data.data)) return false;
|
||||
if (data.data.length === 0) return false;
|
||||
|
||||
// 检查至少有一个有效的 sentences 字段
|
||||
return data.data.some(item => item && item.sentences);
|
||||
// 检查至少有一个有效的 query_part 或 sentences 字段
|
||||
return data.data.some(item => item && (item.query_part || item.sentences));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user