菜单修改

This commit is contained in:
仲么了
2023-12-26 16:17:30 +08:00
parent c37fdba0e7
commit 0d24db0aca
10 changed files with 307 additions and 1996 deletions

View File

@@ -19,6 +19,7 @@ import { useEventListener } from '@vueuse/core'
import { isEmpty } from 'lodash-es'
import { setNavTabsWidth } from '@/utils/layout'
import { adminBaseRoutePath } from '@/router/static'
import { getRouteMenu } from '@/api/auth'
defineOptions({
components: { Default, Classic, Streamline, Double }
@@ -49,111 +50,38 @@ const init = () => {
/**
* 后台初始化请求,获取站点配置,动态路由等信息
*/
handleAdminRoute([
{
id: 1,
pid: 0,
type: 'menu',
title: '控制台',
name: 'dashboard',
path: 'dashboard',
icon: 'fa fa-dashboard',
menu_type: 'tab',
url: '',
component: '/src/views/dashboard/index.vue',
keepalive: 'dashboard',
extend: 'none',
children: [
{
id: 94,
pid: 1,
type: 'button',
title: '查看',
name: 'dashboard/index',
path: '',
icon: '',
menu_type: null,
url: '',
component: '',
keepalive: 0,
extend: 'none'
getRouteMenu().then((res: any) => {
const handlerMenu = (data: any) => {
data.forEach((item: any) => {
item.path = item.routeName || item.title
item.name = item.routeName || item.title
item.component = '/src/views/dashboard/index.vue'
item.type = item.children && item.children.length > 0 ? 'menu_dir' : 'menu'
item.menu_type = item.children && item.children.length > 0 ? null : 'tab'
if (item.children) {
handlerMenu(item.children)
}
]
},
{
id: 3,
pid: 0,
type: 'menu',
title: '测试1',
name: 'test',
path: 'test',
icon: 'fa fa-dashboard',
menu_type: 'tab',
url: '',
component: '/src/views/dashboard/test.vue',
keepalive: 'test',
extend: 'none'
},
{
id: 2,
pid: 0,
type: 'menu_dir',
title: '权限管理',
name: 'auth',
path: 'auth',
icon: 'fa fa-group',
menu_type: null,
url: '',
component: '',
keepalive: 0,
extend: 'none',
children: [
{
id: 3,
pid: 2,
type: 'menu',
title: '角色管理',
name: 'auth/role',
path: 'auth/role',
icon: 'fa fa-group',
menu_type: 'tab',
url: '',
component: '/src/views/auth/role.vue',
keepalive: 'auth/role',
extend: 'none',
children: []
},
{
id: 13,
pid: 2,
type: 'menu',
title: '菜单规则管理',
name: 'auth/menu',
path: 'auth/menu',
icon: 'el-icon-Grid',
menu_type: 'tab',
url: '',
component: '/src/views/auth/menu/index.vue',
keepalive: 'auth/menu',
extend: 'none',
children: []
}
]
})
}
])
// 预跳转到上次路径
if (route.params.to) {
const lastRoute = JSON.parse(route.params.to as string)
if (lastRoute.path != adminBaseRoutePath) {
let query = !isEmpty(lastRoute.query) ? lastRoute.query : {}
routePush({ path: lastRoute.path, query: query })
return
}
}
handlerMenu(res.data)
handleAdminRoute(res.data)
// 跳转到第一个菜单
let firstRoute = getFirstRoute(navTabs.state.tabsViewRoutes)
if (firstRoute) routePush(firstRoute.path)
// 跳转到上次路径
if (route.params.to) {
const lastRoute = JSON.parse(route.params.to as string)
if (lastRoute.path != adminBaseRoutePath) {
let query = !isEmpty(lastRoute.query) ? lastRoute.query : {}
routePush({ path: lastRoute.path, query: query })
return
}
}
// 跳转到第一个菜单
console.log(navTabs.state.tabsViewRoutes)
let firstRoute = getFirstRoute(navTabs.state.tabsViewRoutes)
console.log(firstRoute)
if (firstRoute) routePush(firstRoute.path)
})
}
const onAdaptiveLayout = () => {