<template>
|
<div class="sticky top0">
|
<div class="header relative pointer">
|
<div @click="$router.push('/home')" class="title">
|
<img src="@/assets/logo.png" alt="">
|
射洪“两客一危”监管平台
|
</div>
|
<div></div>
|
<div class="flex a-center pr--40">
|
<div class="flex a-center mr--72">
|
<img src="@/assets/header/photo.png" class="w--32 h--32 shrink0 mr--10" />
|
<div class="fs-- 18 lh--25 color2">admin</div>
|
</div>
|
<div class="dropdown" @mouseenter="toggleDropdown(true)" @mouseleave="toggleDropdown(false)">
|
<img src="@/assets/header/more.png" class="w--16 h--16" />
|
<div v-if="isOpen" class="dropdown-menu">
|
<div class="dropdown-item" v-for="item in menuItems" :key="item.text">
|
<i :class="item.icon"></i> {{ item.text }}
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
<div class="menu w100 bgColor1">
|
<div v-for="(item, index) in routesList" :key="index" class="flex a-center h100">
|
<div v-if="!item.meta || !item.meta.title" class="h100">
|
<div v-for="(item2, index2) in item.children" :key="index2" class="h100">
|
<div @click="$router.push(item2.path)" v-if="!item2.meta.hide"
|
class="flex a-center j-center h100 w--160 menuItemHover pointer"
|
:class="item2.path == $route.path && 'bgColor2'">
|
<img v-if="item2.meta.icon" :src="require(`@/assets/routerIcon/${item2.meta.icon}.png`)"
|
class="w--15 h--15 mr--12 shrink0" />
|
<div class="color1">
|
{{ item2.meta.title }}
|
</div>
|
</div>
|
</div>
|
</div>
|
<div v-else :class="$route.path.includes('systemManage') && 'bgColor2'"
|
class="h100 w--160 menuItemHover dropdown" @mouseenter="routerDropdown(true)"
|
@mouseleave="routerDropdown(false)">
|
<div class="flex a-center j-center h100">
|
<img :src="require(`@/assets/routerIcon/${item.meta.icon}.png`)"
|
class="w--15 h--15 mr--12 shrink0" />
|
<div class="color1">
|
{{ item.meta.title }}
|
</div>
|
</div>
|
<div v-if="routerIsOpen" class="dropdown-menu positionTwo">
|
<div @click="$router.push(item.path + '/' + item2.path), routerIsOpen = false"
|
class="dropdown-item flex a-center" v-for="(item2, index2) in item.children" :key="index2">
|
{{ item2.meta.title }}
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
<router-view></router-view>
|
</div>
|
</template>
|
|
<script>
|
import routes from '@/router/router'
|
export default {
|
data() {
|
return {
|
routesList: routes,
|
isOpen: false,
|
routerIsOpen: false,
|
menuItems: [
|
{ text: '密码设置' },
|
{ text: '退出登录' },
|
]
|
};
|
},
|
created() {
|
},
|
methods: {
|
toggleDropdown(state) {
|
this.isOpen = state;
|
},
|
routerDropdown(state) {
|
this.routerIsOpen = state;
|
}
|
}
|
}
|
</script>
|
|
<style lang="less" scoped>
|
.bgColor1 {
|
background-color: #0E6EFD;
|
}
|
|
.bgColor2 {
|
background: #0D55B9;
|
}
|
|
.color1 {
|
color: #fff;
|
}
|
|
.color2 {
|
color: rgba(0, 0, 0, .6);
|
}
|
|
.header {
|
height: 80px;
|
background: #fff;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
|
.title {
|
display: flex;
|
justify-content: center;
|
font-weight: 600;
|
font-size: 24px;
|
align-items: center;
|
position: absolute;
|
top: 50%;
|
left: 50%;
|
transform: translate(-50%, -50%);
|
color: rgba(0, 0, 0, .8);
|
|
img {
|
width: 40px;
|
height: 40px;
|
margin-right: 10px;
|
}
|
}
|
}
|
|
.menu {
|
height: 60px;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
}
|
|
.menuItemHover:hover {
|
background: #0D55B9;
|
}
|
|
.dropdown {
|
position: relative;
|
display: inline-block;
|
cursor: pointer;
|
}
|
|
.positionTwo {
|
transform: unset !important;
|
width: 160px !important;
|
}
|
|
.dropdown-menu {
|
position: absolute;
|
top: 100%;
|
left: 0;
|
transform: translateX(-50%);
|
background: white;
|
border: 1px solid #ccc;
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
z-index: 1000;
|
border-radius: 8px;
|
}
|
|
.dropdown-item {
|
padding: 8px 16px;
|
white-space: nowrap;
|
/* 防止文本换行 */
|
}
|
|
.dropdown-item:hover {
|
background-color: #f0f0f0;
|
/* 添加 hover 效果 */
|
}
|
</style>
|