1404/11/04- first
This commit is contained in:
@@ -0,0 +1,292 @@
|
||||
<template>
|
||||
|
||||
<div :class="[prefixCls, `${layoutStore.layout}-menu`]">
|
||||
<!-- :selectedKeys="selectedKeys"-->
|
||||
<AMenu :mode="layoutStore.sideMenu.mode" v-model:selectedKeys="selectedKeys" >
|
||||
<template v-for="item in menu">
|
||||
<BasicSubMenu
|
||||
v-if="!item.meta?.hideChildren && item.children && item.children.length > 0"
|
||||
:menu-item="item"
|
||||
:key="item.name"
|
||||
:level="1"
|
||||
/>
|
||||
<!-- <AMenuItem
|
||||
v-else
|
||||
:disabled="item.meta.disabled ?? false"
|
||||
:key="item.name"
|
||||
@click="handleClickMenuItem(item)"
|
||||
>
|
||||
<template #icon>
|
||||
<BaseIcon :size="menuIconSize" v-if="item.meta.icon" :icon="item.meta.icon" />
|
||||
</template>
|
||||
<span>{{ item.meta.title ?? item.name }}</span>
|
||||
<!– <template #title>1111</template>–>
|
||||
<!– <div class="flex"></div>–>
|
||||
</AMenuItem>-->
|
||||
<BaseMenuItem v-else :item="item" :key="item.name"/>
|
||||
</template>
|
||||
|
||||
|
||||
</AMenu >
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {usePrefix} from '@core/composable/usePrefix'
|
||||
//import { menuIconSize } from '@root/config'
|
||||
import {computed} from 'vue'
|
||||
import type {ComputedRef} from 'vue'
|
||||
import {sortBy} from 'lodash'
|
||||
//import { routes } from '@/core/router/routes'
|
||||
import BasicSubMenu from '@core/layouts/composnts/BasicSubMenu.vue'
|
||||
import {useLayoutStore} from '@core/stores/layout'
|
||||
import BaseMenuItem from '@core/layouts/composnts/BaseMenuItem.vue'
|
||||
import type {RouteRecordName, RouteRecordRaw} from 'vue-router'
|
||||
import {useRouterStore} from '@core/stores/router'
|
||||
|
||||
const {prefixCls} = usePrefix('basic-menu')
|
||||
const layoutStore = useLayoutStore()
|
||||
const currentRoute = useRoute()
|
||||
const selectedKeys = ref<(RouteRecordName | undefined)[]>([])
|
||||
const routerStore = useRouterStore()
|
||||
/*const selectedKeys = computed(() => {
|
||||
const path: (RouteRecordName | undefined)[] = []
|
||||
|
||||
function walkInRoutes(routes: RouteRecordRaw[]) {
|
||||
for (const route of routes) {
|
||||
if (route.name == currentRoute.name) {
|
||||
path.push(route.name)
|
||||
return true
|
||||
}
|
||||
if (route.children && route.children.length > 0) {
|
||||
path.push(route.name)
|
||||
const res = walkInRoutes(route.children)
|
||||
if (!res) {
|
||||
path.pop()
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
walkInRoutes(routes)
|
||||
|
||||
return path
|
||||
})*/
|
||||
|
||||
onMounted(() => {
|
||||
//console.log('aaa')
|
||||
|
||||
const path: (RouteRecordName | undefined)[] = []
|
||||
|
||||
function walkInRoutes(routes: RouteRecordRaw[]) {
|
||||
for (const route of routes) {
|
||||
if (route.name == currentRoute.name) {
|
||||
path.push(route.name)
|
||||
return true
|
||||
}
|
||||
if (route.children && route.children.length > 0) {
|
||||
path.push(route.name)
|
||||
const res = walkInRoutes(route.children)
|
||||
if (!res) {
|
||||
path.pop()
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
walkInRoutes(routerStore.routes)
|
||||
selectedKeys.value = path
|
||||
|
||||
// return path
|
||||
|
||||
})
|
||||
|
||||
const menu: ComputedRef<RouteRecordRaw[]> = computed(() => {
|
||||
return sortBy(routerStore.routes, (item) => {
|
||||
return item.meta?.order
|
||||
}).filter((item) => !item.meta?.hideMenu)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
@prefix: ~ '@{prefixCls}-basic-menu';
|
||||
.@{prefix} {
|
||||
|
||||
&.top-menu {
|
||||
@apply pr-5;
|
||||
//display: inline-flex;
|
||||
.ant-menu {
|
||||
// @apply gap-3;
|
||||
//@apply flex-inline;
|
||||
//@apply grid;
|
||||
}
|
||||
|
||||
.ant-menu-horizontal:not(.ant-menu-dark) > .ant-menu-item, .ant-menu-horizontal:not(.ant-menu-dark) > .ant-menu-submenu {
|
||||
padding: 0 5px;
|
||||
}
|
||||
|
||||
/*TODO check for line bottom menu*/
|
||||
|
||||
.ant-menu-horizontal > .ant-menu-item::after, .ant-menu-horizontal > .ant-menu-submenu::after {
|
||||
right: 0 !important;
|
||||
left: 0 !important;
|
||||
}
|
||||
|
||||
.ant-menu-horizontal > .ant-menu-item-selected::after, .ant-menu-horizontal > .ant-menu-submenu-selected::after {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
border-bottom: 2px solid @primary-color;
|
||||
transition: border-color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
|
||||
content: '';
|
||||
}
|
||||
|
||||
.ant-menu-item-selected {
|
||||
//background-color: red;
|
||||
background-color: lighten(@primary-color, 53%);
|
||||
|
||||
/*.ant-menu-horizontal:not(.ant-menu-dark) > .ant-menu-item:after{
|
||||
border-bottom: 5px solid red;
|
||||
background-color: red;
|
||||
}*/
|
||||
|
||||
/*& > .ant-menu-item::after {
|
||||
position: absolute;
|
||||
right: 20px;
|
||||
bottom: 0;
|
||||
left: 20px;
|
||||
border-bottom: 2px solid #0052d9;
|
||||
transition: border-color 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
|
||||
content: '';
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
.ant-menu-item {
|
||||
margin-left: 12px;
|
||||
}
|
||||
|
||||
/*.ant-menu-item:not(.ant-menu-item-disabled):not(.ant-menu-item-selected):hover,
|
||||
.ant-menu-submenu .ant-menu-submenu-title:not(.ant-menu-item-disabled):hover
|
||||
{
|
||||
border-radius:unset !important;
|
||||
}*/
|
||||
|
||||
//display: inline-flex;
|
||||
//justify-content: center;
|
||||
}
|
||||
|
||||
.ant-menu-item, .ant-menu-submenu-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
& .ant-menu-item-icon {
|
||||
margin-right: unset !important;
|
||||
}
|
||||
}
|
||||
|
||||
/** start style for horizontal menu */
|
||||
|
||||
.ant-menu-horizontal {
|
||||
padding: 0 !important;
|
||||
|
||||
li {
|
||||
padding: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
/** end style for horizontal menu */
|
||||
|
||||
&-side-menu {
|
||||
.ant-menu-item:not(.ant-menu-item-disabled):not(.ant-menu-item-selected):hover,
|
||||
.ant-menu-submenu .ant-menu-submenu-title:not(.ant-menu-item-disabled):hover {
|
||||
transition: background-color 0.9ms linear;
|
||||
border-radius: var(--border-radius-base);
|
||||
color: unset !important;
|
||||
//color: red;
|
||||
background-color: #f3f3f3 !important;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* .ant-menu-inline-collapsed{
|
||||
.ant-menu-item,.ant-menu-submenu-title{
|
||||
//display: block;
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
.ant-menu {
|
||||
padding: 10px;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.ant-menu-title-content {
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
.ant-menu-item, .ant-menu-submenu-title {
|
||||
//padding: unset !important;
|
||||
@apply px-2 !important;
|
||||
}
|
||||
|
||||
|
||||
.ant-menu.ant-menu-inline-collapsed > .ant-menu-item .ant-menu-item-icon + span,
|
||||
.ant-menu.ant-menu-inline-collapsed > .ant-menu-submenu .ant-menu-item-icon + span {
|
||||
display: none !important;
|
||||
/*display: flex !important;
|
||||
flex-direction: column !important;
|
||||
justify-content: center !important;*/
|
||||
}
|
||||
|
||||
.ant-menu.ant-menu-inline-collapsed > .ant-menu-submenu > .ant-menu-submenu-title {
|
||||
padding: 0 !important;
|
||||
display: flex !important;
|
||||
align-items: center !important;
|
||||
justify-content: center !important;
|
||||
}
|
||||
|
||||
|
||||
//,.ant-menu.ant-menu-inline-collapsed > .ant-menu-submenu
|
||||
.ant-menu.ant-menu-inline-collapsed > .ant-menu-item {
|
||||
padding: 0 !important;
|
||||
display: flex !important;
|
||||
align-items: center !important;
|
||||
justify-content: center !important;
|
||||
}
|
||||
|
||||
.ant-menu-vertical > .ant-menu-submenu > .ant-menu-submenu-title {
|
||||
height: 36px;
|
||||
}
|
||||
|
||||
|
||||
/*.ant-menu-submenu-title,.ant-menu-submenu-arrow{
|
||||
//color: #f3f3f3 !important;
|
||||
}*/
|
||||
|
||||
|
||||
.ant-menu-item.ant-menu-item-selected {
|
||||
//border-radius: var(--border-radius-base);
|
||||
&::after {
|
||||
content: unset;
|
||||
}
|
||||
}
|
||||
|
||||
.ant-menu.ant-menu-sub.ant-menu-inline {
|
||||
background-color: unset !important;
|
||||
}
|
||||
|
||||
.ant-menu-vertical > .ant-menu-submenu,
|
||||
.ant-menu-vertical > .ant-menu-item {
|
||||
height: 36px;
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user