13404089107
2025-03-04 215530a0eb78faad5e3a0e7b0d695bb6485dcf15
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<template>
    <div class="sticky top0">
        <div class="header relative">
            <div 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-for="(item2, index2) in item.children" :key="index2" class="h100">
                    <div @click="$router.push(item2.path)" v-if="!item2.hide"
                        class="flex a-center h100 px--40 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>
        <router-view :key="key"></router-view>
    </div>
</template>
 
<script>
import routes from '@/router/router'
export default {
    data() {
        return {
            routesList: routes,
            isOpen: false,
            menuItems: [
                { text: '密码设置' },
                { text: '退出登录' },
            ]
        };
    },
    created() {
    },
    methods: {
        toggleDropdown(state) {
            this.isOpen = 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;
}
 
.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>