perf: 对搜索菜单组件进行优化 (#106)
This commit is contained in:
parent
f12f33014e
commit
5f0e91c5ec
@ -7,9 +7,7 @@ interface Props {
|
|||||||
total: number
|
total: number
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const props = defineProps<Props>()
|
||||||
total: 0
|
|
||||||
})
|
|
||||||
|
|
||||||
const appStore = useAppStore()
|
const appStore = useAppStore()
|
||||||
const isMobile = computed(() => appStore.device === DeviceEnum.Mobile)
|
const isMobile = computed(() => appStore.device === DeviceEnum.Mobile)
|
||||||
|
@ -5,7 +5,7 @@ import { useAppStore } from "@/store/modules/app"
|
|||||||
import { usePermissionStore } from "@/store/modules/permission"
|
import { usePermissionStore } from "@/store/modules/permission"
|
||||||
import SearchResult from "./SearchResult.vue"
|
import SearchResult from "./SearchResult.vue"
|
||||||
import SearchFooter from "./SearchFooter.vue"
|
import SearchFooter from "./SearchFooter.vue"
|
||||||
import { ElScrollbar } from "element-plus"
|
import { ElMessage, ElScrollbar } from "element-plus"
|
||||||
import { cloneDeep, debounce } from "lodash-es"
|
import { cloneDeep, debounce } from "lodash-es"
|
||||||
import { DeviceEnum } from "@/constants/app-key"
|
import { DeviceEnum } from "@/constants/app-key"
|
||||||
|
|
||||||
@ -119,7 +119,11 @@ const handleDown = () => {
|
|||||||
/** 键盘回车键 */
|
/** 键盘回车键 */
|
||||||
const handleEnter = () => {
|
const handleEnter = () => {
|
||||||
const { length } = resultList.value
|
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 })
|
router.push({ name: activeRouteName.value })
|
||||||
handleClose()
|
handleClose()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user