搜索优化
This commit is contained in:
parent
9fea2c8a8c
commit
605110fa56
|
|
@ -581,16 +581,24 @@ export default {
|
||||||
container.classList.add('prefetched')
|
container.classList.add('prefetched')
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSearch: debounce(async function () {
|
handleSearch() {
|
||||||
|
// 点击时立即显示 loading 状态
|
||||||
|
this.searching = true
|
||||||
|
// 调用防抖的搜索函数
|
||||||
|
this._handleSearchDebounced()
|
||||||
|
},
|
||||||
|
_handleSearchDebounced: debounce(async function () {
|
||||||
const keyword = this.keyword.trim()
|
const keyword = this.keyword.trim()
|
||||||
if (!keyword) {
|
if (!keyword) {
|
||||||
this.resetSearch()
|
this.resetSearch()
|
||||||
|
this.searching = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!this.pdfDoc) {
|
||||||
|
this.searching = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!this.pdfDoc) return
|
|
||||||
|
|
||||||
// if (this.searching) return
|
|
||||||
this.searching = true
|
|
||||||
await this.$nextTick()
|
await this.$nextTick()
|
||||||
try {
|
try {
|
||||||
const allPrepared = this.pageTextDivs.length === this.totalPages && this.pageTextDivs.every(items => items && items.length)
|
const allPrepared = this.pageTextDivs.length === this.totalPages && this.pageTextDivs.every(items => items && items.length)
|
||||||
|
|
@ -602,7 +610,6 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
await this.highlightMatches()
|
await this.highlightMatches()
|
||||||
} finally {
|
} finally {
|
||||||
this.searching = false
|
this.searching = false
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue