搜索优化
This commit is contained in:
parent
9fea2c8a8c
commit
605110fa56
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue