summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorClariS <[email protected]>2023-08-14 17:08:44 +0800
committerGitHub <[email protected]>2023-08-14 17:08:44 +0800
commit5f0e91c5ec1edcd6909b0a1991ededee3f3dbee6 (patch)
tree76cd5fe14bcdecb90f9c5dc42d3d153232215199 /src
parentf12f33014e75a5d730a7115f888104041c0d4523 (diff)
perf: 对搜索菜单组件进行优化 (#106)
Diffstat (limited to 'src')
-rw-r--r--src/components/SearchMenu/SearchFooter.vue4
-rw-r--r--src/components/SearchMenu/SearchModal.vue8
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()
}