Merge pull request #286 from yanbowe/main
perf(components): Optimize internationalized menu search code
This commit is contained in:
commit
ecbb96f3a5
@ -84,20 +84,11 @@ watch(show, async val => {
|
||||
/** 查询 */
|
||||
function search() {
|
||||
resultOptions.value = routeStore.searchMenus.filter(menu => {
|
||||
return (
|
||||
(keyword.value &&
|
||||
menu.meta?.i18nTitle &&
|
||||
$t(menu.meta?.i18nTitle)
|
||||
.toLocaleLowerCase()
|
||||
.includes(keyword.value.toLocaleLowerCase().trim())) ||
|
||||
menu.meta?.title.toLocaleLowerCase().includes(keyword.value.toLocaleLowerCase().trim())
|
||||
);
|
||||
const trimKeyword = keyword.value.toLocaleLowerCase().trim();
|
||||
const title = (menu.meta.i18nTitle ? $t(menu.meta.i18nTitle) : menu.meta.title).toLocaleLowerCase();
|
||||
return trimKeyword && title.includes(trimKeyword);
|
||||
});
|
||||
if (resultOptions.value?.length > 0) {
|
||||
activePath.value = resultOptions.value[0].path;
|
||||
} else {
|
||||
activePath.value = '';
|
||||
}
|
||||
activePath.value = resultOptions.value[0]?.path ?? '';
|
||||
}
|
||||
|
||||
function handleClose() {
|
||||
|
Loading…
Reference in New Issue
Block a user