|
@@ -18,7 +18,12 @@
|
|
|
>
|
|
>
|
|
|
|
|
|
|
|
<template v-for="item in appRouter.router.sider.route" :key="item.path">
|
|
<template v-for="item in appRouter.router.sider.route" :key="item.path">
|
|
|
- <a-sub-menu v-if="item.children && item.children.filter(_ => !_.hidden)" :key="item.path" >
|
|
|
|
|
|
|
+ <a-menu-item v-if="!item.children" :key="item.path" @click="changeRoute(item)" >
|
|
|
|
|
+ <user-outlined />
|
|
|
|
|
+ <span>{{item.name}}</span>
|
|
|
|
|
+ </a-menu-item>
|
|
|
|
|
+
|
|
|
|
|
+ <a-sub-menu v-else >
|
|
|
<template #title>
|
|
<template #title>
|
|
|
<user-outlined />
|
|
<user-outlined />
|
|
|
<span>
|
|
<span>
|
|
@@ -29,10 +34,6 @@
|
|
|
<user-outlined />{{_.name}}
|
|
<user-outlined />{{_.name}}
|
|
|
</a-menu-item>
|
|
</a-menu-item>
|
|
|
</a-sub-menu>
|
|
</a-sub-menu>
|
|
|
- <a-menu-item v-if="!item.children" :key="item.path" @click="changeRoute(item)" >
|
|
|
|
|
- <user-outlined />
|
|
|
|
|
- <span>{{item.name}}</span>
|
|
|
|
|
- </a-menu-item>
|
|
|
|
|
</template>
|
|
</template>
|
|
|
</a-menu>
|
|
</a-menu>
|
|
|
</a-layout-sider>
|
|
</a-layout-sider>
|
|
@@ -54,6 +55,8 @@ import { MenuFoldOutlined, MenuUnfoldOutlined, UserOutlined } from '@ant-design/
|
|
|
const emitter = useEmitter()
|
|
const emitter = useEmitter()
|
|
|
const appRouter = useAppRouter()
|
|
const appRouter = useAppRouter()
|
|
|
|
|
|
|
|
|
|
+console.log(appRouter)
|
|
|
|
|
+
|
|
|
const onCollapse = () => {}
|
|
const onCollapse = () => {}
|
|
|
const onBreakpoint = () => {}
|
|
const onBreakpoint = () => {}
|
|
|
|
|
|
|
@@ -63,8 +66,6 @@ const selectedKeys2 = ref<string[]>([appRouter.router.sider!.selectPath])
|
|
|
const openKeys = ref<string[]>(appRouter.router.sider!.openKeys)
|
|
const openKeys = ref<string[]>(appRouter.router.sider!.openKeys)
|
|
|
|
|
|
|
|
emitter.on(Emitter.NAVBAR, () => {
|
|
emitter.on(Emitter.NAVBAR, () => {
|
|
|
- console.log('[appRouter.router.sider!.selectPath]:', [appRouter.router.sider!.selectPath])
|
|
|
|
|
-
|
|
|
|
|
selectedKeys2.value = [appRouter.router.sider!.selectPath]
|
|
selectedKeys2.value = [appRouter.router.sider!.selectPath]
|
|
|
openKeys.value = appRouter.router.sider!.openKeys
|
|
openKeys.value = appRouter.router.sider!.openKeys
|
|
|
})
|
|
})
|
|
@@ -73,6 +74,26 @@ const changeRoute = (route: Router.RoutesProps) => {
|
|
|
RootRouter.push(route.path)
|
|
RootRouter.push(route.path)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+const hasOneShowingChild = (children = [], parent) => {
|
|
|
|
|
+ const showingChildren = children.filter(item => {
|
|
|
|
|
+ if (item.hidden) {
|
|
|
|
|
+ return false
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return true
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ if (showingChildren.length === 1) {
|
|
|
|
|
+ return true
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (showingChildren.length === 0) {
|
|
|
|
|
+ return true
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return false
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="less" scoped >
|
|
<style lang="less" scoped >
|