Template
1
0
mirror of https://github.com/un-pany/v3-admin-vite.git synced 2025-04-21 03:19:19 +08:00

perf: 对搜索菜单组件进行优化 (#106)

This commit is contained in:
ClariS 2023-08-14 17:08:44 +08:00 committed by GitHub
parent f12f33014e
commit 5f0e91c5ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -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)

View File

@ -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()
}