搜索优化

This commit is contained in:
cwchen 2025-11-28 09:35:48 +08:00
parent 9fea2c8a8c
commit 605110fa56
1 changed files with 12 additions and 5 deletions

View File

@ -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