|
|
@ -18,7 +18,9 @@ import {
|
|
|
|
ref,
|
|
|
|
ref,
|
|
|
|
shallowRef,
|
|
|
|
shallowRef,
|
|
|
|
watch,
|
|
|
|
watch,
|
|
|
|
type Ref
|
|
|
|
type Ref,
|
|
|
|
|
|
|
|
computed,
|
|
|
|
|
|
|
|
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'
|
|
|
@ -54,7 +56,7 @@ interface Result {
|
|
|
|
text?: string
|
|
|
|
text?: string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const { localeIndex } = useData()
|
|
|
|
const { localeIndex, theme } = useData()
|
|
|
|
|
|
|
|
|
|
|
|
const searchIndex = computedAsync(async () =>
|
|
|
|
const searchIndex = computedAsync(async () =>
|
|
|
|
markRaw(
|
|
|
|
markRaw(
|
|
|
@ -80,6 +82,19 @@ const showDetailedList = useLocalStorage(
|
|
|
|
false
|
|
|
|
false
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const disableDetailedView = computed(() => {
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
theme.value.search?.provider === 'local' &&
|
|
|
|
|
|
|
|
theme.value.search.options?.disableDetailedView === true
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
watchEffect(() => {
|
|
|
|
|
|
|
|
if (disableDetailedView.value) {
|
|
|
|
|
|
|
|
showDetailedList.value = false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const results: Ref<(SearchResult & Result)[]> = shallowRef([])
|
|
|
|
const results: Ref<(SearchResult & Result)[]> = shallowRef([])
|
|
|
|
|
|
|
|
|
|
|
|
const contents = shallowRef(new Map<string, Map<string, string>>())
|
|
|
|
const contents = shallowRef(new Map<string, Map<string, string>>())
|
|
|
@ -158,21 +173,16 @@ debouncedWatch(
|
|
|
|
title = title.replace(reg, `<mark>$&</mark>`)
|
|
|
|
title = title.replace(reg, `<mark>$&</mark>`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (match.includes('titles')) {
|
|
|
|
if (match.includes('titles')) {
|
|
|
|
titles = titles.flatMap((t) =>
|
|
|
|
titles = titles
|
|
|
|
t ? [t.replace(reg, `<mark>$&</mark>`)] : []
|
|
|
|
.map((t) => t?.replace(reg, `<mark>$&</mark>`))
|
|
|
|
)
|
|
|
|
.filter(Boolean)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (showDetailedListValue && match.includes('text')) {
|
|
|
|
if (showDetailedListValue && match.includes('text')) {
|
|
|
|
text = text.replace(reg, `<mark>$&</mark>`)
|
|
|
|
text = text.replace(reg, `<mark>$&</mark>`)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
return { ...r, title, titles, text }
|
|
|
|
...r,
|
|
|
|
|
|
|
|
title,
|
|
|
|
|
|
|
|
titles,
|
|
|
|
|
|
|
|
text
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
contents.value = c
|
|
|
|
contents.value = c
|
|
|
|
|
|
|
|
|
|
|
@ -272,9 +282,6 @@ onKeyStroke('Escape', () => {
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// Translations
|
|
|
|
// Translations
|
|
|
|
|
|
|
|
|
|
|
|
const { theme } = useData()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const defaultTranslations: { modal: ModalTranslations } = {
|
|
|
|
const defaultTranslations: { modal: ModalTranslations } = {
|
|
|
|
modal: {
|
|
|
|
modal: {
|
|
|
|
displayDetails: 'Display detailed list',
|
|
|
|
displayDetails: 'Display detailed list',
|
|
|
@ -364,10 +371,9 @@ useEventListener('popstate', (event) => {
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
<div class="search-actions">
|
|
|
|
<div class="search-actions">
|
|
|
|
<button
|
|
|
|
<button
|
|
|
|
|
|
|
|
v-if="!disableDetailedView"
|
|
|
|
class="toggle-layout-button"
|
|
|
|
class="toggle-layout-button"
|
|
|
|
:class="{
|
|
|
|
:class="{ 'detailed-list': showDetailedList }"
|
|
|
|
'detailed-list': showDetailedList
|
|
|
|
|
|
|
|
}"
|
|
|
|
|
|
|
|
:title="$t('modal.displayDetails')"
|
|
|
|
:title="$t('modal.displayDetails')"
|
|
|
|
@click="showDetailedList = !showDetailedList"
|
|
|
|
@click="showDetailedList = !showDetailedList"
|
|
|
|
>
|
|
|
|
>
|
|
|
@ -746,6 +752,7 @@ useEventListener('popstate', (event) => {
|
|
|
|
background-color: var(--vp-c-highlight-bg);
|
|
|
|
background-color: var(--vp-c-highlight-bg);
|
|
|
|
color: var(--vp-c-highlight-text);
|
|
|
|
color: var(--vp-c-highlight-text);
|
|
|
|
border-radius: 2px;
|
|
|
|
border-radius: 2px;
|
|
|
|
|
|
|
|
padding: 0 4px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.excerpt :deep(.vp-code-group) .tabs {
|
|
|
|
.excerpt :deep(.vp-code-group) .tabs {
|
|
|
|