|
|
@ -8,9 +8,11 @@ import {
|
|
|
|
useLocalStorage,
|
|
|
|
useLocalStorage,
|
|
|
|
useSessionStorage
|
|
|
|
useSessionStorage
|
|
|
|
} from '@vueuse/core'
|
|
|
|
} from '@vueuse/core'
|
|
|
|
|
|
|
|
import Mark from 'mark.js'
|
|
|
|
import MiniSearch, { type SearchResult } from 'minisearch'
|
|
|
|
import MiniSearch, { type SearchResult } from 'minisearch'
|
|
|
|
import { useRouter } from 'vitepress'
|
|
|
|
import { useRouter } from 'vitepress'
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
|
|
|
|
computed,
|
|
|
|
createApp,
|
|
|
|
createApp,
|
|
|
|
markRaw,
|
|
|
|
markRaw,
|
|
|
|
nextTick,
|
|
|
|
nextTick,
|
|
|
@ -18,9 +20,8 @@ import {
|
|
|
|
ref,
|
|
|
|
ref,
|
|
|
|
shallowRef,
|
|
|
|
shallowRef,
|
|
|
|
watch,
|
|
|
|
watch,
|
|
|
|
type Ref,
|
|
|
|
watchEffect,
|
|
|
|
computed,
|
|
|
|
type Ref
|
|
|
|
watchEffect
|
|
|
|
|
|
|
|
} from 'vue'
|
|
|
|
} from 'vue'
|
|
|
|
import type { ModalTranslations } from '../../../../types/local-search'
|
|
|
|
import type { ModalTranslations } from '../../../../types/local-search'
|
|
|
|
import { pathToFile, withBase } from '../../app/utils'
|
|
|
|
import { pathToFile, withBase } from '../../app/utils'
|
|
|
@ -177,9 +178,6 @@ debouncedWatch(
|
|
|
|
.map((t) => t?.replace(reg, `<mark>$&</mark>`))
|
|
|
|
.map((t) => t?.replace(reg, `<mark>$&</mark>`))
|
|
|
|
.filter(Boolean)
|
|
|
|
.filter(Boolean)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (showDetailedListValue && match.includes('text')) {
|
|
|
|
|
|
|
|
text = text.replace(reg, `<mark>$&</mark>`)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return { ...r, title, titles, text }
|
|
|
|
return { ...r, title, titles, text }
|
|
|
@ -188,10 +186,11 @@ debouncedWatch(
|
|
|
|
|
|
|
|
|
|
|
|
await nextTick()
|
|
|
|
await nextTick()
|
|
|
|
const excerpts = el.value?.querySelectorAll('.result .excerpt') ?? []
|
|
|
|
const excerpts = el.value?.querySelectorAll('.result .excerpt') ?? []
|
|
|
|
|
|
|
|
let i = 0
|
|
|
|
for (const excerpt of excerpts) {
|
|
|
|
for (const excerpt of excerpts) {
|
|
|
|
excerpt.querySelector('mark')?.scrollIntoView({
|
|
|
|
new Mark(excerpt as HTMLElement).mark(Object.keys(results.value[i].match))
|
|
|
|
block: 'center'
|
|
|
|
excerpt.querySelector('mark')?.scrollIntoView({ block: 'center' })
|
|
|
|
})
|
|
|
|
i += 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{ debounce: 200, immediate: true }
|
|
|
|
{ debounce: 200, immediate: true }
|
|
|
@ -526,7 +525,7 @@ useEventListener('popstate', (event) => {
|
|
|
|
</Teleport>
|
|
|
|
</Teleport>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped lang="postcss">
|
|
|
|
<style scoped>
|
|
|
|
.VPLocalSearchBox {
|
|
|
|
.VPLocalSearchBox {
|
|
|
|
position: fixed;
|
|
|
|
position: fixed;
|
|
|
|
z-index: 100;
|
|
|
|
z-index: 100;
|
|
|
|