diff options
| author | ClariS <[email protected]> | 2023-08-14 17:08:44 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-08-14 17:08:44 +0800 |
| commit | 5f0e91c5ec1edcd6909b0a1991ededee3f3dbee6 (patch) | |
| tree | 76cd5fe14bcdecb90f9c5dc42d3d153232215199 | |
| parent | f12f33014e75a5d730a7115f888104041c0d4523 (diff) | |
perf: 对搜索菜单组件进行优化 (#106)
| -rw-r--r-- | src/components/SearchMenu/SearchFooter.vue | 4 | ||||
| -rw-r--r-- | src/components/SearchMenu/SearchModal.vue | 8 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/components/SearchMenu/SearchFooter.vue b/src/components/SearchMenu/SearchFooter.vue index 80031de..b30cfd5 100644 --- a/src/components/SearchMenu/SearchFooter.vue +++ b/src/components/SearchMenu/SearchFooter.vue @@ -7,9 +7,7 @@ interface Props { total: number } -const props = withDefaults(defineProps<Props>(), { - total: 0 -}) +const props = defineProps<Props>() const appStore = useAppStore() const isMobile = computed(() => appStore.device === DeviceEnum.Mobile) diff --git a/src/components/SearchMenu/SearchModal.vue b/src/components/SearchMenu/SearchModal.vue index 1fc4c4b..f7db586 100644 --- a/src/components/SearchMenu/SearchModal.vue +++ b/src/components/SearchMenu/SearchModal.vue @@ -5,7 +5,7 @@ import { useAppStore } from "@/store/modules/app" import { usePermissionStore } from "@/store/modules/permission" import SearchResult from "./SearchResult.vue" import SearchFooter from "./SearchFooter.vue" -import { ElScrollbar } from "element-plus" +import { ElMessage, ElScrollbar } from "element-plus" import { cloneDeep, debounce } from "lodash-es" import { DeviceEnum } from "@/constants/app-key" @@ -119,7 +119,11 @@ const handleDown = () => { /** 键盘回车键 */ const handleEnter = () => { const { length } = resultList.value - if (length === 0 || !activeRouteName.value) return + if (length === 0) return + if (!activeRouteName.value) { + ElMessage.error("无法通过搜索功能进入该菜单,请为对应的路由设置唯一的 Name") + return + } router.push({ name: activeRouteName.value }) handleClose() } |
