diff options
Diffstat (limited to 'packages/frontend/src/components/MkSuperMenu.vue')
| -rw-r--r-- | packages/frontend/src/components/MkSuperMenu.vue | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/packages/frontend/src/components/MkSuperMenu.vue b/packages/frontend/src/components/MkSuperMenu.vue index 5c89a6530d..dbc673333c 100644 --- a/packages/frontend/src/components/MkSuperMenu.vue +++ b/packages/frontend/src/components/MkSuperMenu.vue @@ -52,9 +52,9 @@ SPDX-License-Identifier: AGPL-3.0-only {{ item.label }} </template> <template v-else> - <span style="opacity: 0.7; font-size: 90%;">{{ item.parentLabels.join(' > ') }}</span> + <span style="opacity: 0.7; font-size: 90%; word-break: break-word;">{{ item.parentLabels.join(' > ') }}</span> <br> - <span>{{ item.label }}</span> + <span style="word-break: break-word;">{{ item.label }}</span> </template> </span> </MkA> @@ -95,7 +95,7 @@ export type SuperMenuDef = { <script lang="ts" setup> import { useTemplateRef, ref, watch, nextTick, computed } from 'vue'; import { getScrollContainer } from '@@/js/scroll.js'; -import type { SearchIndexItem } from '@/utility/settings-search-index.js'; +import type { SearchIndexItem } from '@/utility/inapp-search.js'; import MkInput from '@/components/MkInput.vue'; import { i18n } from '@/i18n.js'; import { useRouter } from '@/router.js'; @@ -165,12 +165,28 @@ watch(rawSearchQuery, (value) => { }); }; - for (const item of searchIndexItemById.values()) { - if ( - compareStringIncludes(item.label, value) || - item.keywords.some((x) => compareStringIncludes(x, value)) - ) { + // label, keywords, texts の順に優先して表示 + + let items = Array.from(searchIndexItemById.values()); + + for (const item of items) { + if (compareStringIncludes(item.label, value)) { + addSearchResult(item); + items = items.filter(i => i.id !== item.id); + } + } + + for (const item of items) { + if (item.keywords.some((x) => compareStringIncludes(x, value))) { + addSearchResult(item); + items = items.filter(i => i.id !== item.id); + } + } + + for (const item of items) { + if (item.texts.some((x) => compareStringIncludes(x, value))) { addSearchResult(item); + items = items.filter(i => i.id !== item.id); } } } |