Skip to content

Commit

Permalink
feat(projects): 搜索菜单增加大小写转换
Browse files Browse the repository at this point in the history
  • Loading branch information
yanbowe authored and buqiyuan committed Dec 31, 2021
1 parent b4c9ba9 commit 7ec9777
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/layout/header/components/search/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<CustomAModal title="搜索菜单" v-model:visible="show" :keyboard="false">
<CustomAModal title="搜索菜单" v-model:visible="show" :keyboard="false" @cancel="handleClose">
<a-input
ref="inputRef"
v-model:value="keyword"
Expand Down Expand Up @@ -79,7 +79,10 @@
function search() {
resultOptions.value = menusList.value.filter((menu) => {
const title = menu.meta?.title as string;
return keyword.value && title.includes(keyword.value.trim());
return (
keyword.value &&
title.toLocaleLowerCase().includes(keyword.value.toLocaleLowerCase().trim())
);
});
if (resultOptions.value?.length > 0) {
activePath.value = resultOptions.value[0].name as string;
Expand All @@ -103,9 +106,12 @@
}
function handleClose() {
resultOptions.value = [];
keyword.value = '';
show.value = false;
/** 延时处理防止用户看到某些操作 */
setTimeout(() => {
resultOptions.value = [];
keyword.value = '';
}, 200);
}
/** key up */
Expand Down
1 change: 0 additions & 1 deletion src/layout/header/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
const userInfo = computed(() => userStore.userInfo);
const searchVisible = ref(false);
const menus = computed(() => {
console.log('route', route, userStore.menus);
if (route.meta?.namePath) {
let children = userStore.menus;
const paths = route.meta?.namePath?.map((item) => {
Expand Down

0 comments on commit 7ec9777

Please sign in to comment.