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