From 605110fa56d73e272bbe28f26909215cd458b701 Mon Sep 17 00:00:00 2001 From: cwchen <1048842385@qq.com> Date: Fri, 28 Nov 2025 09:35:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/common/DocumentSearch.vue | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/views/common/DocumentSearch.vue b/src/views/common/DocumentSearch.vue index b2617bb..0185563 100644 --- a/src/views/common/DocumentSearch.vue +++ b/src/views/common/DocumentSearch.vue @@ -581,16 +581,24 @@ export default { container.classList.add('prefetched') }, - handleSearch: debounce(async function () { + handleSearch() { + // 点击时立即显示 loading 状态 + this.searching = true + // 调用防抖的搜索函数 + this._handleSearchDebounced() + }, + _handleSearchDebounced: debounce(async function () { const keyword = this.keyword.trim() if (!keyword) { this.resetSearch() + this.searching = false + return + } + if (!this.pdfDoc) { + this.searching = false return } - if (!this.pdfDoc) return - // if (this.searching) return - this.searching = true await this.$nextTick() try { const allPrepared = this.pageTextDivs.length === this.totalPages && this.pageTextDivs.every(items => items && items.length) @@ -602,7 +610,6 @@ export default { } } - await this.highlightMatches() } finally { this.searching = false