|
|
@ -41,15 +41,15 @@ |
|
|
|
<!-- </el-menu-item>--> |
|
|
|
<!-- </el-sub-menu>--> |
|
|
|
<div v-if="item?.children && item.children.length > 0"> |
|
|
|
<div class="px-[20px] relative h-[60px] w-[95px] flex justify-center items-center"> |
|
|
|
<h3 class="text-white cursor-pointer" @mouseenter="mouseenter(index)" @mouseleave="mouseleave(index)"> |
|
|
|
<div class="px-[20px] relative h-[60px] w-[95px] flex justify-center items-center top-menu"> |
|
|
|
<h3 class="text-white cursor-pointer"> |
|
|
|
{{ |
|
|
|
item.title |
|
|
|
}}</h3> |
|
|
|
<div v-if="item.showChild" |
|
|
|
class="absolute top-[60px] bg-white p-2 shadow border-t-2 border-[#409eff] left-0 overflow-hidden" |
|
|
|
:style="{height: `${item.childHeight}px`}"> |
|
|
|
<div v-for="(sub,subIndex) in item.children" :key="index" class="w-[200px] p-1 cursor-pointer hover:text-[#409eff]"> |
|
|
|
<div |
|
|
|
class="absolute top-[60px] bg-white p-2 shadow border-t-2 border-[#409eff] left-0 overflow-hidden child-menu"> |
|
|
|
<div v-for="(sub,subIndex) in item.children" :key="index" |
|
|
|
class="w-[200px] p-1 cursor-pointer hover:text-[#409eff]"> |
|
|
|
<el-space |
|
|
|
@click="openSpmUrl(`${item.path}`,sub,sub.navigationId)"> |
|
|
|
<el-avatar v-if="sub.icon" :src="sub.icon" shape="square" |
|
|
@ -60,10 +60,9 @@ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<el-menu-item v-else :index="`${item.path}`"><h3 |
|
|
|
@mouseenter="mouseenter(index)" |
|
|
|
@mouseleave="mouseleave(index)" |
|
|
|
@click="openSpmUrl(`${item.path}`,item,item.navigationId)" class="text-white">{{ item.title }}</h3> |
|
|
|
<el-menu-item v-else :index="`${item.path}`"> |
|
|
|
<h3 |
|
|
|
@click="openSpmUrl(`${item.path}`,item,item.navigationId)" class="text-white">{{ item.title }}</h3> |
|
|
|
</el-menu-item> |
|
|
|
</template> |
|
|
|
</el-menu> |
|
|
@ -93,7 +92,7 @@ |
|
|
|
</el-dropdown> |
|
|
|
</template> |
|
|
|
<template v-else> |
|
|
|
<!-- <el-button type="primary" v-if="!token" @click="navigateTo(`/passport/login`)">登录/注册</el-button>--> |
|
|
|
<!-- <el-button type="primary" v-if="!token" @click="navigateTo(`/passport/login`)">登录/注册</el-button>--> |
|
|
|
<!-- <el-button v-if="config.showLoginButton" circle :icon="ElIconUserFilled" @click="goLogin"></el-button>--> |
|
|
|
</template> |
|
|
|
</ClientOnly> |
|
|
@ -117,7 +116,7 @@ |
|
|
|
<el-dropdown-item divided @click="loginDeveloperCenterByToken">会员中心</el-dropdown-item> |
|
|
|
<el-dropdown-item divided command="logOut" @click="navigateTo('/user/logout')">退出</el-dropdown-item> |
|
|
|
</template> |
|
|
|
<!-- <el-dropdown-item v-if="!token" divided @click="navigateTo(`/passport/login`)">登录</el-dropdown-item>--> |
|
|
|
<!-- <el-dropdown-item v-if="!token" divided @click="navigateTo(`/passport/login`)">登录</el-dropdown-item>--> |
|
|
|
</el-dropdown-menu> |
|
|
|
</template> |
|
|
|
</el-dropdown> |
|
|
@ -160,66 +159,16 @@ const sysDomain = useSysDomain(); |
|
|
|
const setNav = () => { |
|
|
|
navigations.value = navigations.value.map(item => { |
|
|
|
item.showChild = false |
|
|
|
item.childHeight = 0; |
|
|
|
item.childHeight = item.children ? parseInt((item.children?.length * 31).toString()) : 0; |
|
|
|
return item |
|
|
|
}) |
|
|
|
nextTick(() => { |
|
|
|
const childMenuList = document.getElementsByClassName('.child-menu') |
|
|
|
console.log('childMenuList', childMenuList) |
|
|
|
}) |
|
|
|
} |
|
|
|
setNav() |
|
|
|
|
|
|
|
const time = 10 |
|
|
|
let interval: NodeJS.Timeout |
|
|
|
const mouseenter = async (index: number) => { |
|
|
|
let showIndex = -1; |
|
|
|
for (let i = 0; i < navigations.value.length; i++) { |
|
|
|
console.log(navigations.value[i].showChild) |
|
|
|
if (navigations.value[i].showChild) { |
|
|
|
showIndex = i |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
if (showIndex === index) return |
|
|
|
const item = navigations.value[index]; |
|
|
|
const childHeight = item.children ? parseInt((item.children?.length * 31).toString()) : 0; |
|
|
|
await hideAll() |
|
|
|
item.showChild = true |
|
|
|
if (item.childHeight === undefined) item.childHeight = 0 |
|
|
|
interval = setInterval(() => { |
|
|
|
if (item.childHeight !== undefined && item.childHeight >= childHeight && interval) clearInterval(interval) |
|
|
|
if (item.childHeight !== undefined && item.children !== undefined && (item.childHeight < childHeight)) { |
|
|
|
item.childHeight += parseInt(((childHeight / item.children?.length) / 5).toString()) |
|
|
|
} else { |
|
|
|
// item.childHeight = childHeight |
|
|
|
if (interval) clearInterval(interval) |
|
|
|
} |
|
|
|
console.log(item.childHeight, childHeight) |
|
|
|
// console.log(item.childHeight) |
|
|
|
}, time) |
|
|
|
} |
|
|
|
|
|
|
|
const mouseleave = () => { |
|
|
|
if (interval) clearInterval(interval) |
|
|
|
} |
|
|
|
|
|
|
|
const hideAll = () => { |
|
|
|
return new Promise(resolve => { |
|
|
|
navigations.value = navigations.value.map(item => { |
|
|
|
if (item.childHeight === undefined) item.childHeight = 0 |
|
|
|
if (item.showChild) { |
|
|
|
const childHeight = item.children ? parseInt((item.children?.length * 31).toString()) : 0; |
|
|
|
const interval = setInterval(() => { |
|
|
|
if (item.childHeight !== undefined && item.children !== undefined && (item.childHeight > 0)) { |
|
|
|
item.childHeight -= parseInt(((childHeight / item.children?.length) / 5).toString()) |
|
|
|
} else { |
|
|
|
item.showChild = false |
|
|
|
clearInterval(interval) |
|
|
|
} |
|
|
|
}, time) |
|
|
|
} |
|
|
|
return item |
|
|
|
}) |
|
|
|
resolve(true) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
// 顶部栏初始数 |
|
|
|
const visibleNumber = ref<number>(6); |
|
|
@ -299,4 +248,25 @@ body { |
|
|
|
.is-active:hover { |
|
|
|
border-bottom: none !important; |
|
|
|
} |
|
|
|
|
|
|
|
.top-menu:hover .child-menu { |
|
|
|
display: block; |
|
|
|
animation: revealMask 0.5s forwards; |
|
|
|
} |
|
|
|
|
|
|
|
.child-menu { |
|
|
|
display: none; |
|
|
|
max-height: 0; /* 初始最大高度为0 */ |
|
|
|
overflow: hidden; /* 隐藏超出部分 */ |
|
|
|
transition: max-height 0.5s ease; /* 平滑过渡 */ |
|
|
|
} |
|
|
|
|
|
|
|
@keyframes revealMask { |
|
|
|
from { |
|
|
|
max-height: 0; |
|
|
|
} |
|
|
|
to { |
|
|
|
max-height: 600px; /* 设置一个足够大的值,确保内容完全显示 */ |
|
|
|
} |
|
|
|
} |
|
|
|
</style> |
|
|
|