浏览代码

feat: 默认首页 于菜单展示支持

lanceJiang 10 月之前
父节点
当前提交
c7aee40ca2
共有 3 个文件被更改,包括 12 次插入13 次删除
  1. 1 1
      src/router/index.ts
  2. 9 10
      src/store/modules/permission.ts
  3. 2 2
      src/styles/index.scss

+ 1 - 1
src/router/index.ts

@@ -4,7 +4,7 @@ import useStore from '@/store'
 
 export const Layout = () => import('@/layout/index.vue')
 
-const HOME_URL = '/dashboard'
+export const HOME_URL = '/dashboard'
 
 // 参数说明: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 // 静态路由

+ 9 - 10
src/store/modules/permission.ts

@@ -4,6 +4,7 @@ import { AppRouteRecordRaw } from '@/router/types'
 import { defineStore } from 'pinia'
 // import { sysStaticRouter, noFoundRouters, constantMenuList } from '@/router'
 import { getMenuList } from '@/api/system/menu'
+import { HOME_URL } from '@/router'
 
 const modules = import.meta.glob('@/views/**/*.vue')
 export const Layout = () => import('@/layout/index.vue') // todo...
@@ -112,6 +113,7 @@ const getFlatMenuList_1children = (menuList: AppRouteRecordRaw[]) => {
 // 过滤隐藏
 // const getShowMenuList = (menuList: AppRouteRecordRaw[], parentPath = '') => {
 const getShowMenuList = (menuList: AppRouteRecordRaw[]) => {
+	console.error(menuList, 'menuList')
 	return menuList.filter(item => {
 		// console.error(item, 'item')
 		if (!item.meta.hidden) {
@@ -140,19 +142,15 @@ const usePermissionStore = defineStore({
 	}),
 	getters: {
 		// 有效的 菜单列表
-		// showMenuList: state => getShowMenuList(JSON.parse(JSON.stringify([...constantMenuList, ...state.menuList]))),
-		showMenuList: state => getShowMenuList(JSON.parse(JSON.stringify(state.menuList))),
-		/*getShowMenuList([
-				...JSON.parse(JSON.stringify(state.menuList)),
-				// 测试
+		showMenuList: state => {
+			return [
+				// 首页
 				{
-					path: 'dashboard',
-					// path: HOME_URL,
-					component: () => import('@/views/dashboard/index-old.vue'),
-					name: 'dashboard',
+					path: HOME_URL,
 					meta: { title: 'dashboard', icon: 'icon-homepage', affix: true }
 				}
-			])*/
+			].concat(getShowMenuList(JSON.parse(JSON.stringify(state.menuList))))
+		},
 		// showMenuList: state => getShowMenuList(JSON.parse(JSON.stringify(state.routes)))
 		// 菜单权限列表 ==> 扁平化之后的一维数组菜单,主要用来添加动态路由
 		showMenuListFlat() {
@@ -188,6 +186,7 @@ const usePermissionStore = defineStore({
 					data!.menu, // .filter((v: any) => /\/.*/.test(v.path)),
 					roles
 				)
+				debugger
 				this.setRoutes(menuList)
 				return menuList
 			})

+ 2 - 2
src/styles/index.scss

@@ -172,10 +172,10 @@ div:focus {
 	}
 }
 
-.aside-box-system {
+/*.aside-box-system {
 	background-color: var(--el-bg-color) !important;
 	margin-right: 10px;
-}
+}*/
 
 .content-warp {
 	flex: 1;