diff --git a/src/layout/components/Sidebar/SidebarItem.vue b/src/layout/components/Sidebar/SidebarItem.vue index aea5cc9..40b7a33 100644 --- a/src/layout/components/Sidebar/SidebarItem.vue +++ b/src/layout/components/Sidebar/SidebarItem.vue @@ -11,29 +11,13 @@ @@ -94,6 +78,7 @@ if (showingChildren.length === 1) { return true } + // Show parent if there are no child router to display if (showingChildren.length === 0) { this.onlyOneChild = { @@ -103,10 +88,10 @@ } return true } + return false }, - resolvePath(routePath) { - + resolvePath(routePath) { if (isExternal(routePath)) { return routePath } @@ -124,11 +109,7 @@ } */ ::v-deep .submenu-item .el-submenu__title { padding: 0 !important; - } - ::v-deep .menuwrap .el-menu-item { - padding: 0 !important; - } - + } ::v-deep .submenu-item .sublink { padding-left: 40px !important; diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js index 3859c95..cd35048 100644 --- a/src/store/modules/permission.js +++ b/src/store/modules/permission.js @@ -120,25 +120,50 @@ export function generaMenu(routes, data) { } else if(/^\^/.test(item.path)){ const menu = { + name: item.children?.length > 1 ? 'menu_' + item.id : item.children[0]?.id, path: pathHandler(item), component: Layout, - children: [{ - path: "", - name: 'menu_' + item.id, - component: (item.url.includes('#')||item.path == '') ? Layout : loadView(item.url), - meta: { - title: item.name, - id: item.id, - roles: ['admin'], - params, - icon: item.icon - } - }, ] + meta: { + title: item.children?.length > 1 ? item.name : item.children[0]?.name, + id: item.children?.length > 1 ? item.id : item.children[0]?.id, + roles: ['admin'], + params, + icon: item.children?.length > 1 ? item.icon : item.children[0]?.icon + }, + children: [] } if (item.children) { + if (item.children.length > 1) { + menu['redirect'] = `${pathHandler(item)}${item.children[0].path}` + item.children.unshift({ + id: item.id, + name: item.name, + path: item.path.replace(/\^/g,""), + url: item.url, + icon: item.icon, + children: [], + hidden: true + }) + } else { + menu.children.push({ + path: "", + name: 'menu_' + item.id, + component: (item.url.includes('#')||item.path == '') ? Layout : loadView(item.url), + // component: Layout, + meta: { + title: item.name, + id: item.id, + roles: ['admin'], + params, + + icon: item.icon + } + }) + } generaMenu(menu.children, item.children) } + console.log(77, menu) routes.push(menu) } else { const menu = { @@ -156,7 +181,8 @@ export function generaMenu(routes, data) { auths:item.has_auth_node_tags, params, icon: item.icon - } + }, + hidden: item.hidden } if(item.path?.includes("$")){ menu.hidden = true diff --git a/src/views/record/index.vue b/src/views/record/index.vue index 6773d06..32ab1bc 100644 --- a/src/views/record/index.vue +++ b/src/views/record/index.vue @@ -299,7 +299,7 @@ // path = '/record/menu_' + item.id + '?time=' + new Date() this.catalogChildren = item.children } else { - path = '/record/index_' + item.id + '?time=' + new Date() + path = '/record/index_' + item.id this.$router.push({ path: path }) diff --git a/vue.config.js b/vue.config.js index 5201527..c82404e 100644 --- a/vue.config.js +++ b/vue.config.js @@ -25,7 +25,7 @@ module.exports = { * Detail: https://cli.vuejs.org/config/#publicpath */ publicPath: process.env.ENV === 'staging' ? '/admin_test' : '/admin', - outputDir: '/Users/mac/Documents/朗业/2024/s-四世同堂-档案/sstt_dangan/public/admin', + outputDir: '/Users/mac/Documents/朗业/2024/s-四世同堂-档案/sstt_dangan/public/admin_test', assetsDir: 'static', css: { loaderOptions: { // 向 CSS 相关的 loader 传递选项