|
|
@@ -492,6 +492,9 @@ const newSourceFile = reactive({
|
|
|
required: true
|
|
|
})
|
|
|
|
|
|
+// 文档结构块(用于生成目录等)
|
|
|
+const blocks = ref([])
|
|
|
+
|
|
|
// 目录数据(从文档结构中提取)
|
|
|
const tocItems = computed(() => {
|
|
|
const items = []
|
|
|
@@ -761,19 +764,23 @@ async function fetchTemplateData() {
|
|
|
const structuredDoc = await documentApi.getStructured(baseDocumentId)
|
|
|
// 将结构化文档的 blocks 和 images 合并渲染
|
|
|
if (structuredDoc && structuredDoc.blocks && structuredDoc.blocks.length > 0) {
|
|
|
+ blocks.value = structuredDoc.blocks // 保存 blocks 用于目录
|
|
|
documentContent.value = renderStructuredDocument(structuredDoc)
|
|
|
// 提取文档中的实体
|
|
|
entities.value = extractEntitiesFromBlocks(structuredDoc.blocks)
|
|
|
} else {
|
|
|
+ blocks.value = []
|
|
|
documentContent.value = emptyPlaceholder
|
|
|
entities.value = []
|
|
|
}
|
|
|
} catch (docError) {
|
|
|
console.warn('获取文档内容失败:', docError)
|
|
|
+ blocks.value = []
|
|
|
documentContent.value = emptyPlaceholder
|
|
|
entities.value = []
|
|
|
}
|
|
|
} else {
|
|
|
+ blocks.value = []
|
|
|
documentContent.value = emptyPlaceholder
|
|
|
entities.value = []
|
|
|
}
|
|
|
@@ -1434,6 +1441,7 @@ async function handleRegenerateBlocks() {
|
|
|
// 重新加载文档内容
|
|
|
const structuredDoc = await documentApi.getStructured(baseDocumentId)
|
|
|
if (structuredDoc && structuredDoc.blocks && structuredDoc.blocks.length > 0) {
|
|
|
+ blocks.value = structuredDoc.blocks // 更新 blocks
|
|
|
documentContent.value = renderStructuredDocument(structuredDoc)
|
|
|
// 重新提取实体
|
|
|
entities.value = extractEntitiesFromBlocks(structuredDoc.blocks)
|