Skip to content

Commit

Permalink
Merge pull request #286 from yanbowe/main
Browse files Browse the repository at this point in the history
perf(components): Optimize internationalized menu search code
  • Loading branch information
honghuangdc authored Oct 18, 2023
2 parents 04d3330 + 296a2d2 commit ecbb96f
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions src/layouts/common/global-search/components/search-modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

1 comment on commit ecbb96f

@vercel
Copy link

@vercel vercel bot commented on ecbb96f Oct 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.