Browse Source

左侧菜单

caozhaorui 9 months ago
parent
commit
f6c3a2d931

+ 2 - 2
snowy-admin-web/src/config/index.js

@@ -30,8 +30,8 @@ const DEFAULT_CONFIG = {
 	// 请求是否开启缓存
 	REQUEST_CACHE: false,
 
-	// 布局 经典:classical,双排菜单:doublerow, 顶栏菜单:top,单一窗口:singlewindow
-	SNOWY_LAYOUT: 'singlewindow',
+	// 布局 经典:classical,双排菜单:doublerow, 顶栏菜单:top,左侧菜单:left
+	SNOWY_LAYOUT: 'left',
 
 	// 菜单是否折叠
 	SNOWY_MENU_COLLAPSE: false,

+ 1 - 1
snowy-admin-web/src/layout/enum/layoutEnum.js

@@ -12,5 +12,5 @@ export const layoutEnum = {
 	CLASSICAL: 'classical',
 	DOUBLEROW: 'doublerow',
 	TOP: 'top',
-	SINGLEWINDOW: 'singlewindow',
+	LEFT: 'left',
 }

+ 32 - 25
snowy-admin-web/src/layout/index.vue

@@ -65,8 +65,8 @@
 		@onSelect="onSelect"
 	/>
 	<!-- 顶部菜单布局 -->
-	<SingleWindowMenu
-		v-else-if="layout === layoutEnum.SINGLEWINDOW"
+	<LeftMenu
+		v-else-if="layout === layoutEnum.LEFT"
 		:layout="layout"
 		:menuList="menuList"
 		:menu="menu"
@@ -101,7 +101,7 @@
 	import ClassicalMenu from '@/layout/menu/classicalMenu.vue'
 	import DoubleRowMenu from '@/layout/menu/doubleRowMenu.vue'
 	import TopMenu from '@/layout/menu/topMenu.vue'
-	import SingleWindowMenu from '@/layout/menu/singleWindowMenu.vue'
+	import LeftMenu from '@/layout/menu/leftMenu.vue'
 
 	const store = globalStore()
 	const kStore = keepAliveStore()
@@ -186,7 +186,7 @@
 				active = traverseChild(pMenu.value.children, active).path
 			}
 			selectedKeys.value = new Array(active)
-			const pidKey = getParentKeys(pMenu.value.children, active)
+			const pidKey = getParentKeys(layout.value === layoutEnum.LEFT ? [pMenu.value] : pMenu.value.children, active)
 			// 判断是隐藏的路由,找其上级
 			if (route.meta.hidden && pidKey) {
 				if (pidKey.length > 1) {
@@ -194,22 +194,25 @@
 				}
 			}
 			const nextTickMenu = pMenu.value.children
-			if (pidKey) {
-				const modelPidKey = getParentKeys(moduleMenu.value, route.path)
-				moduleMenu.value.forEach((item) => {
-					if (modelPidKey.includes(item.path)) {
-						tagSwitchModule(item.id)
-					}
-				})
-				const parentPath = pidKey[pidKey.length - 1]
-				if (layout.value === layoutEnum.DOUBLEROW) {
-					// 这一串操作下来只为取到最上面的路由的孩子们,最后成为双排菜单的第二排
-					const nextMenuTemp = nextTickMenu.filter((item) => item.path === parentPath)[0].children
-					if (nextMenuTemp) {
-						nextMenu.value = nextTickMenu.filter((item) => item.path === parentPath)[0].children
+			if (layout.value !== layoutEnum.LEFT) {
+				if (pidKey) {
+					const modelPidKey = getParentKeys(moduleMenu.value, route.path)
+					moduleMenu.value.forEach((item) => {
+						if (modelPidKey.includes(item.path)) {
+							tagSwitchModule(item.id)
+						}
+					})
+					const parentPath = pidKey[pidKey.length - 1]
+					if (layout.value === layoutEnum.DOUBLEROW) {
+						// 这一串操作下来只为取到最上面的路由的孩子们,最后成为双排菜单的第二排
+						const nextMenuTemp = nextTickMenu.filter((item) => item.path === parentPath)[0].children
+						if (nextMenuTemp) {
+							nextMenu.value = nextTickMenu.filter((item) => item.path === parentPath)[0].children
+						}
 					}
 				}
 			}
+
 			if (!onSelectTag.value || sideUniqueOpen.value) {
 				openKeys.value = pidKey
 			}
@@ -223,17 +226,21 @@
 	// 执行-start
 	moduleMenu.value = router.getMenu()
 	// 获取缓存中的菜单模块是哪个
-	const menuModuleId = tool.data.get('SNOWY_MENU_MODULE_ID')
-	if (menuModuleId) {
-		// 防止切换一个无此应用的人
-		const module = router.getMenu().filter((item) => item.id === menuModuleId)
-		if (module.length > 0) {
-			menu.value = module[0].children
+	if (layout.value === layoutEnum.LEFT) {
+		menu.value = router.getMenu()
+	} else {
+		const menuModuleId = tool.data.get('SNOWY_MENU_MODULE_ID')
+		if (menuModuleId) {
+			// 防止切换一个无此应用的人
+			const module = router.getMenu().filter((item) => item.id === menuModuleId)
+			if (module.length > 0) {
+				menu.value = module[0].children
+			} else {
+				menu.value = router.getMenu()[0].children
+			}
 		} else {
 			menu.value = router.getMenu()[0].children
 		}
-	} else {
-		menu.value = router.getMenu()[0].children
 	}
 	showThis()
 	onMounted(() => {

snowy-admin-web/src/layout/menu/singleWindowMenu.vue → snowy-admin-web/src/layout/menu/leftMenu.vue