diff --git a/src/layout/LayoutColumns/index.vue b/src/layout/LayoutColumns/index.vue index ff352ee..3e2aa3b 100644 --- a/src/layout/LayoutColumns/index.vue +++ b/src/layout/LayoutColumns/index.vue @@ -1,12 +1,57 @@ @@ -14,25 +59,135 @@ import { ref, computed, watch } from "vue"; import { useRoute, useRouter } from "vue-router"; import {usePermissionStore} from "@/store/modules/permission" +import { useSettingStore } from "@/store/modules/setting"; +import SubItem from '../components/SubMenu/SubItem.vue' +import TagsView from '../components/TagsView/index.vue' const PermissionStore = usePermissionStore() - +const SettingStore = useSettingStore() const route = useRoute() - +const router = useRouter(); +import HeaderToolRight from '../components/Header/ToolRight.vue' +import HeaderToolLeft from '../components/Header/ToolLeft.vue' +import Main from '../components/Main/index.vue' // 获取路由 const permission_routes = computed(() => PermissionStore.permission_routes) +// 获取路由 +const menusRoutes = computed(()=>{ + return PermissionStore.permission_routes.filter(item=>!item.hidden) +}) +// 主题配置 +const themeConfig = computed(() =>SettingStore.themeConfig) +const isCollapse = computed(() =>!SettingStore.isCollapse) +const activeMenu = computed(() => { + const { meta, path } = route + if (meta.activeMenu) { + return meta.activeMenu + } + return path +}) +const basePath = ref('/') +const subMenus = ref([]) + +watch(()=>[menusRoutes,route],()=>{ + console.log('===============================',route,route.path,menusRoutes) + if (!menusRoutes.value.length) return; + let menuItem = menusRoutes.value.find(item=>{ + return item.path === route.path || `/${route.path.split("/")[1]}` === item.path + }) + if(menuItem.children?.length) { + subMenus.value = menuItem.children + }else { + subMenus.value = [] + } + console.log('route.path',route.path.split('/')) + basePath.value = `/${route.path.split("/")[1]}` + + + console.log('menuItem.value',subMenus.value,basePath) + +},{ + deep: true, + immediate:true +}) + + +const handleChangeMenu = (item)=>{ + if (item.children?.length) { + subMenus.value = item.children + }else { + subMenus.value = []; + } + console.log('item.path',item.path) + router.push(item.path); + +} + +console.log('permission_routes',menusRoutes.value,) + diff --git a/src/layout/components/SubMenu/SubItem.vue b/src/layout/components/SubMenu/SubItem.vue index 73d6938..ce0416e 100644 --- a/src/layout/components/SubMenu/SubItem.vue +++ b/src/layout/components/SubMenu/SubItem.vue @@ -43,6 +43,7 @@ const props = defineProps({ const onlyOneChild = ref(null) const hasOneShowingChild = (children = [], parent) => { + const showingChildren = children.filter((item) => { // 过滤掉需要隐藏的菜单 if (item.hidden) { @@ -53,14 +54,14 @@ const hasOneShowingChild = (children = [], parent) => { return true } }) - // 当只有一个子路由器时,默认情况下会显示该子路由器 if (showingChildren.length === 1) { return true } // 如果没有要显示的子路由器,则显示父路由器 if (showingChildren.length === 0) { - onlyOneChild.value = { ...parent, path: '', noShowingChildren: true } + // onlyOneChild.value = { ...parent, path: '', noShowingChildren: true } + onlyOneChild.value = { ...parent, noShowingChildren: true } return true } @@ -74,6 +75,8 @@ const resolvePath = (routePath) => { if (isExternal(props.basePath)) { return props.basePath } - return path.resolve(props.basePath, routePath) + let path2 = path.resolve(props.basePath, routePath) + console.log('============',path2) + return path2 } diff --git a/src/layout/components/SubMenu/SubMenu.vue b/src/layout/components/SubMenu/SubMenu.vue new file mode 100644 index 0000000..2c41665 --- /dev/null +++ b/src/layout/components/SubMenu/SubMenu.vue @@ -0,0 +1,33 @@ + + + diff --git a/src/layout/index.vue b/src/layout/index.vue index 0ce7ff0..afd891e 100644 --- a/src/layout/index.vue +++ b/src/layout/index.vue @@ -1,9 +1,10 @@ @@ -15,12 +16,14 @@ import { useResizeHandler } from './hooks/useResizeHandler' import LayoutVertical from './LayoutVertical/index.vue' import LayoutHorizontal from './LayoutHorizontal/index.vue' + import LayoutColumns from './LayoutColumns/index.vue' const SettingStore = useSettingStore() const themeConfig = computed(() => SettingStore.themeConfig) const LayoutComponents = { horizontal: LayoutHorizontal, vertical: LayoutVertical, + columns: LayoutColumns, }; // 是否折叠 diff --git a/src/routers/index.ts b/src/routers/index.ts index 0190f89..6827898 100644 --- a/src/routers/index.ts +++ b/src/routers/index.ts @@ -73,6 +73,7 @@ export const constantRoutes: Array = [ name: 'layout', component: Layout, redirect: '/home', + meta: { title: '首页', icon: 'House', }, children: [ { path: '/home', diff --git a/src/routers/modules/table.ts b/src/routers/modules/table.ts index a69aef5..d37e445 100644 --- a/src/routers/modules/table.ts +++ b/src/routers/modules/table.ts @@ -20,15 +20,15 @@ const tableRouter = [{ meta: { title: '综合表格', keepAlive: true , icon: 'MenuIcon'} }, { - path: 'inline-table', + path: 'inlineTable', component: () => import('@/views/table/InlineEditTable/index.vue'), - name: 'inline-table', + name: 'inlineTable', meta: { title: '行内编辑', keepAlive: true , icon: 'MenuIcon'} }, { path: 'editableProTable', component: () => import('@/views/table/EditableProTable/index.vue'), - name: 'edit-table', + name: 'editableProTable', meta: { title: '可编辑表格', keepAlive: true , icon: 'MenuIcon'} }, // {