|
@@ -94,7 +94,7 @@
|
|
|
v-for="report in filteredReports"
|
|
v-for="report in filteredReports"
|
|
|
:key="report.id"
|
|
:key="report.id"
|
|
|
class="report-item"
|
|
class="report-item"
|
|
|
- :class="{ active: currentDocumentId && currentDocumentId === report.baseDocumentId }"
|
|
|
|
|
|
|
+ :class="{ active: currentReportId === report.id }"
|
|
|
@click="switchReport(report)"
|
|
@click="switchReport(report)"
|
|
|
>
|
|
>
|
|
|
<div class="report-icon">📄</div>
|
|
<div class="report-icon">📄</div>
|
|
@@ -581,6 +581,9 @@ const templateStore = useTemplateStore()
|
|
|
// 从 URL 查询参数获取文档ID
|
|
// 从 URL 查询参数获取文档ID
|
|
|
const currentDocumentId = ref(route.query.doc || null)
|
|
const currentDocumentId = ref(route.query.doc || null)
|
|
|
|
|
|
|
|
|
|
+// 当前选中的报告ID(用于标记左侧列表的选中状态)
|
|
|
|
|
+const currentReportId = ref(null)
|
|
|
|
|
+
|
|
|
// 是否有当前激活的文档
|
|
// 是否有当前激活的文档
|
|
|
const hasActiveDocument = computed(() => !!currentDocumentId.value)
|
|
const hasActiveDocument = computed(() => !!currentDocumentId.value)
|
|
|
|
|
|
|
@@ -689,13 +692,34 @@ async function loadMyReports() {
|
|
|
// 切换报告
|
|
// 切换报告
|
|
|
async function switchReport(report) {
|
|
async function switchReport(report) {
|
|
|
// 如果点击的是当前已选中的报告,则取消选中
|
|
// 如果点击的是当前已选中的报告,则取消选中
|
|
|
- if (currentDocumentId.value === report.baseDocumentId) {
|
|
|
|
|
|
|
+ if (currentDocumentId.value && currentDocumentId.value === report.baseDocumentId) {
|
|
|
|
|
+ unselectReport()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 如果是当前选中的空白报告(无 baseDocumentId),也取消选中
|
|
|
|
|
+ if (!report.baseDocumentId && currentReportId.value === report.id) {
|
|
|
unselectReport()
|
|
unselectReport()
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 更新当前报告ID(用于标记选中状态)
|
|
|
|
|
+ currentReportId.value = report.id
|
|
|
|
|
+
|
|
|
if (!report.baseDocumentId) {
|
|
if (!report.baseDocumentId) {
|
|
|
- ElMessage.warning('该报告还没有关联文档')
|
|
|
|
|
|
|
+ // 没有关联文档,进入空白编辑页面
|
|
|
|
|
+ currentDocumentId.value = 'empty-' + report.id // 使用特殊标识表示空白文档
|
|
|
|
|
+ reportTitle.value = report.name || '未命名报告'
|
|
|
|
|
+
|
|
|
|
|
+ // 清空文档内容,显示空白提示
|
|
|
|
|
+ blocks.value = []
|
|
|
|
|
+ tocItems.value = []
|
|
|
|
|
+ documentContent.value = emptyPlaceholder
|
|
|
|
|
+ entities.value = []
|
|
|
|
|
+ sourceFiles.value = []
|
|
|
|
|
+
|
|
|
|
|
+ // 切换到资源 Tab
|
|
|
|
|
+ leftPanelTab.value = 'files'
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -721,8 +745,9 @@ function unselectReport() {
|
|
|
newUrl.searchParams.delete('doc')
|
|
newUrl.searchParams.delete('doc')
|
|
|
window.history.replaceState({}, '', newUrl.toString())
|
|
window.history.replaceState({}, '', newUrl.toString())
|
|
|
|
|
|
|
|
- // 清除当前文档
|
|
|
|
|
|
|
+ // 清除当前文档和报告
|
|
|
currentDocumentId.value = null
|
|
currentDocumentId.value = null
|
|
|
|
|
+ currentReportId.value = null
|
|
|
reportTitle.value = '新建报告'
|
|
reportTitle.value = '新建报告'
|
|
|
|
|
|
|
|
// 清空文档内容
|
|
// 清空文档内容
|
|
@@ -1152,14 +1177,16 @@ onMounted(async () => {
|
|
|
// 只有 URL 明确指定了文档才加载
|
|
// 只有 URL 明确指定了文档才加载
|
|
|
currentDocumentId.value = docId
|
|
currentDocumentId.value = docId
|
|
|
await loadDocumentById(docId)
|
|
await loadDocumentById(docId)
|
|
|
- // 找到对应的报告设置标题
|
|
|
|
|
|
|
+ // 找到对应的报告设置标题和ID
|
|
|
const report = myReports.value.find(r => r.baseDocumentId === docId)
|
|
const report = myReports.value.find(r => r.baseDocumentId === docId)
|
|
|
if (report) {
|
|
if (report) {
|
|
|
reportTitle.value = report.name || '未命名报告'
|
|
reportTitle.value = report.name || '未命名报告'
|
|
|
|
|
+ currentReportId.value = report.id
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- // 没有指定文档,显示空白编辑器,不自动选中任何报告
|
|
|
|
|
|
|
+ // 没有指定文档,显示欢迎页,不自动选中任何报告
|
|
|
reportTitle.value = '新建报告'
|
|
reportTitle.value = '新建报告'
|
|
|
|
|
+ currentReportId.value = null
|
|
|
documentContent.value = emptyPlaceholder
|
|
documentContent.value = emptyPlaceholder
|
|
|
}
|
|
}
|
|
|
} catch (err) {
|
|
} catch (err) {
|