diff --git a/src/views/analysis/components/child/DocumentPreviewPanel.vue b/src/views/analysis/components/child/DocumentPreviewPanel.vue index 3fd3faa..442b194 100644 --- a/src/views/analysis/components/child/DocumentPreviewPanel.vue +++ b/src/views/analysis/components/child/DocumentPreviewPanel.vue @@ -17,14 +17,14 @@
-
- +
+
-
- +
+
-
- +
+
@@ -249,7 +249,7 @@ export default { .document-item { padding: 7px 16px; border-radius: 8px; - background: #f1f9ff; + background: #fff; color: #303133; font-size: 13px; line-height: 1.4; diff --git a/src/views/common/DocumentSearchWord.vue b/src/views/common/DocumentSearchWord.vue index 3427d5e..2b601c4 100644 --- a/src/views/common/DocumentSearchWord.vue +++ b/src/views/common/DocumentSearchWord.vue @@ -92,9 +92,13 @@ export default { } }, mounted() { - if (!this.docUrl) { - const initialUrl = this.fileUrl || this.$route?.query?.url || DEFAULT_DOC_URL + // 优先使用 fileUrl prop,然后是路由参数,最后是默认 URL + const initialUrl = this.fileUrl || this.$route?.query?.url || DEFAULT_DOC_URL + if (initialUrl && initialUrl !== this.docUrl) { this.applyDocUrl(initialUrl) + } else if (this.docUrl && !this.docRendered) { + // 如果 docUrl 已设置但文档未渲染,重新加载 + this.loadDocument() } }, beforeDestroy() { @@ -104,9 +108,16 @@ export default { watch: { fileUrl: { immediate: true, - handler(newVal) { - if (newVal) { + handler(newVal, oldVal) { + // 当 fileUrl 变化时,总是重新加载文档 + if (newVal && newVal !== oldVal) { this.applyDocUrl(newVal) + } else if (newVal && !this.docUrl) { + // 如果新值存在但 docUrl 为空,也加载 + this.applyDocUrl(newVal) + } else if (!newVal && this.docUrl) { + // 如果新值为空但 docUrl 有值,重置状态 + this.resetViewerState() } } }, @@ -134,12 +145,16 @@ export default { }, applyDocUrl(url) { const resolved = url || '' - if (resolved === this.docUrl) { - if (resolved) { - this.loadDocument() - } + // 如果 URL 相同且文档已渲染,不重复加载 + if (resolved === this.docUrl && this.docRendered) { return } + // 如果 URL 变化,先取消之前的请求和重置状态 + if (resolved !== this.docUrl) { + this.cancelFetch() + this.cancelScrollAnimation() + this.resetViewerState() + } this.docUrl = resolved if (this.docUrl) { this.loadDocument() @@ -1405,7 +1420,7 @@ export default { } .state-icon { - font-size: 48px; + font-size: 24px; color: #409EFF; animation: rotate 1s linear infinite; }