word 文档搜索修改

This commit is contained in:
cwchen 2025-11-28 13:12:43 +08:00
parent acdd310656
commit 04f81d279a
1 changed files with 47 additions and 4 deletions

View File

@ -327,10 +327,18 @@ export default {
if (!this.docRendered) { if (!this.docRendered) {
this.prepareSearchSegments() this.prepareSearchSegments()
} }
// searching
this.searching = true this.searching = true
// 使 requestAnimationFrame DOM
await this.$nextTick() await this.$nextTick()
await new Promise(resolve => requestAnimationFrame(() => {
requestAnimationFrame(resolve)
}))
try { try {
this.highlightMatches() //
const searchPromise = Promise.resolve(this.highlightMatches())
const minDelayPromise = new Promise(resolve => setTimeout(resolve, 300))
await Promise.all([searchPromise, minDelayPromise])
} finally { } finally {
this.searching = false this.searching = false
} }
@ -1014,9 +1022,19 @@ export default {
pointer-events: none; pointer-events: none;
} }
.search-toolbar.is-searching::after { .search-toolbar.is-searching {
border-color: rgba(43, 104, 255, 0.4); &::after {
animation: search-pulse 1.2s ease-in-out infinite; border-color: rgba(43, 104, 255, 0.4);
animation: search-pulse 1.2s ease-in-out infinite;
}
//
.search-icon {
i.el-icon-loading {
display: inline-block !important;
animation: rotating 1s linear infinite !important;
}
}
} }
@keyframes search-pulse { @keyframes search-pulse {
@ -1100,6 +1118,17 @@ export default {
.search-icon { .search-icon {
background: #2b68ff; background: #2b68ff;
color: #fff; color: #fff;
//
i.el-icon-loading {
display: inline-block;
animation: rotating 1s linear infinite;
font-size: 16px;
}
i.el-icon-search {
font-size: 16px;
}
} }
.search-icon:hover { .search-icon:hover {
@ -1107,6 +1136,20 @@ export default {
color: #fff; color: #fff;
} }
.search-icon:disabled {
opacity: 0.8;
cursor: wait;
}
@keyframes rotating {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.search-status { .search-status {
display: flex; display: flex;
align-items: center; align-items: center;