|
|
@@ -10,6 +10,14 @@
|
|
|
/>
|
|
|
<span class="save-status" v-if="saved">✓ 已保存</span>
|
|
|
<div class="toolbar-right">
|
|
|
+ <el-button
|
|
|
+ :icon="Refresh"
|
|
|
+ :loading="regenerating"
|
|
|
+ @click="handleRegenerateBlocks"
|
|
|
+ title="重新生成文档结构"
|
|
|
+ >
|
|
|
+ 重新生成
|
|
|
+ </el-button>
|
|
|
<el-button :icon="Clock">版本</el-button>
|
|
|
<el-button :icon="Share">分享</el-button>
|
|
|
<el-divider direction="vertical" />
|
|
|
@@ -302,7 +310,7 @@
|
|
|
import { ref, reactive, computed, onMounted, onUnmounted } from 'vue'
|
|
|
import { useRouter, useRoute } from 'vue-router'
|
|
|
import {
|
|
|
- ArrowLeft, Clock, Share, Check, Plus, Delete, Connection
|
|
|
+ ArrowLeft, Clock, Share, Check, Plus, Delete, Connection, Refresh
|
|
|
} from '@element-plus/icons-vue'
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
import { useTemplateStore } from '@/stores/template'
|
|
|
@@ -318,6 +326,7 @@ const viewMode = ref('edit')
|
|
|
const saved = ref(true)
|
|
|
const editorRef = ref(null)
|
|
|
const loading = ref(false)
|
|
|
+const regenerating = ref(false)
|
|
|
|
|
|
// 来源文件(从 API 获取)
|
|
|
const sourceFiles = ref([])
|
|
|
@@ -439,6 +448,34 @@ function handleSave() {
|
|
|
ElMessage.success('保存成功')
|
|
|
}
|
|
|
|
|
|
+// 重新生成文档块结构
|
|
|
+async function handleRegenerateBlocks() {
|
|
|
+ const baseDocumentId = templateStore.currentTemplate?.baseDocumentId
|
|
|
+ if (!baseDocumentId) {
|
|
|
+ ElMessage.warning('没有关联的示例文档')
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ regenerating.value = true
|
|
|
+ try {
|
|
|
+ const result = await documentApi.regenerateBlocks(baseDocumentId)
|
|
|
+ ElMessage.success(`重新生成成功: ${result.blockCount} 个文档块, ${result.entityCount} 个实体`)
|
|
|
+
|
|
|
+ // 重新加载文档内容
|
|
|
+ const structuredDoc = await documentApi.getStructured(baseDocumentId)
|
|
|
+ if (structuredDoc && structuredDoc.blocks && structuredDoc.blocks.length > 0) {
|
|
|
+ documentContent.value = structuredDoc.blocks
|
|
|
+ .map(block => block.markedHtml || block.html || block.plainText || '')
|
|
|
+ .join('')
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('重新生成失败:', error)
|
|
|
+ ElMessage.error('重新生成失败: ' + (error.message || '未知错误'))
|
|
|
+ } finally {
|
|
|
+ regenerating.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function getFileIcon(file) {
|
|
|
return '📄'
|
|
|
}
|