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() {
|
function search() {
|
||||||
resultOptions.value = routeStore.searchMenus.filter(menu => {
|
resultOptions.value = routeStore.searchMenus.filter(menu => {
|
||||||
return (
|
const trimKeyword = keyword.value.toLocaleLowerCase().trim();
|
||||||
(keyword.value &&
|
const title = (menu.meta.i18nTitle ? $t(menu.meta.i18nTitle) : menu.meta.title).toLocaleLowerCase();
|
||||||
menu.meta?.i18nTitle &&
|
return trimKeyword && title.includes(trimKeyword);
|
||||||
$t(menu.meta?.i18nTitle)
|
|
||||||
.toLocaleLowerCase()
|
|
||||||
.includes(keyword.value.toLocaleLowerCase().trim())) ||
|
|
||||||
menu.meta?.title.toLocaleLowerCase().includes(keyword.value.toLocaleLowerCase().trim())
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
if (resultOptions.value?.length > 0) {
|
activePath.value = resultOptions.value[0]?.path ?? '';
|
||||||
activePath.value = resultOptions.value[0].path;
|
|
||||||
} else {
|
|
||||||
activePath.value = '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleClose() {
|
function handleClose() {
|
||||||
|
Loading…
Reference in New Issue
Block a user