1404/11/04- first
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<template>
|
||||
<AMenuItem
|
||||
:disabled="props.item.meta?.disabled ?? false"
|
||||
:key="props.item.name"
|
||||
@click="handleClickMenuItem(item)"
|
||||
>
|
||||
<template #icon>
|
||||
<BaseIcon :size="menuIconSize" v-if="props.item.meta?.icon" :icon="props.item.meta?.icon" />
|
||||
</template>
|
||||
<span>{{ props.item.meta.title ?? props.item.name }}</span>
|
||||
<!-- <template #title>1111</template>-->
|
||||
<!-- <div class="flex"></div>-->
|
||||
</AMenuItem>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { menuIconSize } from '@root/config'
|
||||
import type { RouteRecordRaw } from 'vue-router'
|
||||
|
||||
const router = useRouter()
|
||||
interface Props {
|
||||
item: RouteRecordRaw
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {})
|
||||
|
||||
async function handleClickMenuItem(item: RouteRecordRaw) {
|
||||
router.push({ name: item.name })
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="less"></style>
|
||||
@@ -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>
|
||||
@@ -0,0 +1,120 @@
|
||||
<template>
|
||||
<!-- <div :class="[prefixCls]">-->
|
||||
<ASubMenu :class="prefixCls" :popupClassName="`${prefixCls}-popup`" :popupOffset="popupOffset">
|
||||
<template #icon>
|
||||
<BaseIcon :size="menuIconSize" v-if="item.meta?.icon" :icon="item.meta.icon" />
|
||||
</template>
|
||||
<template #title>
|
||||
<span>{{ item.meta.title ?? item.name }}</span>
|
||||
</template>
|
||||
<template v-for="childItem in menu">
|
||||
<BasicSubMenu
|
||||
v-if="!childItem.meta?.hideChildren && childItem.children && childItem.children.length > 0"
|
||||
:menu-item="childItem"
|
||||
:key="childItem.name"
|
||||
:level="props.level + 1"
|
||||
/>
|
||||
<!-- <AMenuItem v-else :key="childItem.name" :disabled="childItem.meta.disabled ?? false">
|
||||
<template #icon>
|
||||
<BaseIcon :size="menuIconSize" v-if="childItem.meta.icon" :icon="childItem.meta.icon" />
|
||||
</template>
|
||||
<span>{{ childItem.meta.title ?? childItem.name }}</span>
|
||||
</AMenuItem>-->
|
||||
<BaseMenuItem v-else :item="childItem" :key="childItem.name" />
|
||||
</template>
|
||||
</ASubMenu>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { usePrefix } from '@core/composable/usePrefix'
|
||||
import { menuIconSize } from '@root/config'
|
||||
import { computed } from 'vue'
|
||||
import { sortBy } from 'lodash'
|
||||
//import { routes } from '@/core/router/routes'
|
||||
import type { RouteRecordRaw } from 'vue-router'
|
||||
import BaseMenuItem from '@core/layouts/composnts/BaseMenuItem.vue'
|
||||
const { prefixCls } = usePrefix('basic-sub-menu')
|
||||
|
||||
interface Props {
|
||||
menuItem: RouteRecordRaw
|
||||
level: string | number
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
level: 1
|
||||
})
|
||||
|
||||
const popupOffset = computed(() => {
|
||||
if (props.level == 1) return [-63, 3]
|
||||
return [-8, -8]
|
||||
})
|
||||
|
||||
const item = computed(() => {
|
||||
return props.menuItem
|
||||
})
|
||||
|
||||
const menu = computed(() => {
|
||||
return sortBy(props.menuItem.children, (item) => {
|
||||
return item.meta?.order
|
||||
}).filter((item) => !item.meta?.hideMenu)
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
@prefix:~ '@{prefixCls}-basic-sub-menu';
|
||||
.@{prefix}{
|
||||
|
||||
&.ant-menu-submenu-selected{
|
||||
border-radius: var(--border-radius-base);
|
||||
background-color: var(--ant-primary-1);
|
||||
.ant-menu-submenu-arrow{
|
||||
color: var(--ant-primary)
|
||||
}
|
||||
}
|
||||
|
||||
&-popup{
|
||||
|
||||
/*padding-right: 20px;*/
|
||||
ul{
|
||||
//display: none;
|
||||
border-radius: var(--border-radius-base);
|
||||
padding: 5px !important;
|
||||
}
|
||||
|
||||
.ant-menu-vertical.ant-menu-sub > .ant-menu-item{
|
||||
display: flex !important;
|
||||
align-items: center;
|
||||
gap:5px;
|
||||
}
|
||||
|
||||
//background-color: red;
|
||||
.ant-menu-vertical > .ant-menu-submenu > .ant-menu-submenu-title{
|
||||
display: flex;
|
||||
padding: 0 5px;
|
||||
gap:5px;
|
||||
align-items: center;
|
||||
height: 36px;
|
||||
}
|
||||
|
||||
li.ant-menu-item{
|
||||
border-radius: var(--border-radius-base);
|
||||
padding:0 5px;
|
||||
}
|
||||
|
||||
.ant-menu-vertical > .ant-menu-item{
|
||||
height: 36px;
|
||||
}
|
||||
|
||||
/* .ant-menu-submenu.ant-menu-submenu-popup{
|
||||
}*/
|
||||
|
||||
.ant-menu-submenu-arrow{
|
||||
right: unset !important;
|
||||
left: 10px;
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user