|
@@ -1,91 +1,63 @@
|
1
|
1
|
<template>
|
2
|
2
|
<div class="featureBox">
|
3
|
|
- <el-menu
|
4
|
|
- :collapse="isCollapse"
|
5
|
|
- :default-active="activeMenu"
|
6
|
|
- class="el-menu-vertical-demo dark-mode"
|
7
|
|
- >
|
8
|
|
- <template v-for="item in menuList" :key="item.key">
|
9
|
|
- <el-sub-menu
|
10
|
|
- class="menuBox"
|
11
|
|
- :index="item.path"
|
12
|
|
- v-if="item.children"
|
13
|
|
- @mouseenter="
|
14
|
|
- (el) => {
|
15
|
|
- moveToMenu(el, item.icon);
|
16
|
|
- }
|
17
|
|
- "
|
18
|
|
- @mouseleave="
|
19
|
|
- (el) => {
|
20
|
|
- leaveToMenu(el, item.icon);
|
21
|
|
- }
|
22
|
|
- "
|
|
3
|
+ <el-menu :default-active="activeMenu">
|
|
4
|
+ <template v-for="menu in menuList">
|
|
5
|
+ <!-- 只有一级菜单 -->
|
|
6
|
+ <el-menu-item
|
|
7
|
+ v-if="!menu.children"
|
|
8
|
+ :index="menu.path"
|
|
9
|
+ @click="jumpRoute(menu)"
|
23
|
10
|
>
|
|
11
|
+ <img :src="getImgUrl(menu)" :alt="menu.name" />
|
|
12
|
+ <span class="muneName">{{ menu.name }}</span>
|
|
13
|
+ </el-menu-item>
|
|
14
|
+ <!-- 有二级菜单 -->
|
|
15
|
+ <el-sub-menu v-else :index="menu.path">
|
24
|
16
|
<template #title>
|
25
|
|
- <img :src="getUrl(item.icon)" alt="" />
|
26
|
|
- <span>{{ item.name }}</span>
|
|
17
|
+ <img :src="getImgUrl(menu)" :alt="menu.name" />
|
|
18
|
+ <span class="muneName">{{ menu.name }}</span>
|
27
|
19
|
</template>
|
28
|
|
- <el-menu-item
|
29
|
|
- :index="son.path"
|
30
|
|
- v-for="son in item.children"
|
31
|
|
- @click="jumpModule(son.path)"
|
|
20
|
+ <el-menu-item-group
|
|
21
|
+ v-for="menuSub in menu.children"
|
|
22
|
+ :key="menuSub.path"
|
32
|
23
|
>
|
33
|
|
- <template #title>
|
34
|
|
- <span class="muneName">{{ son.name }}</span>
|
35
|
|
- </template>
|
36
|
|
- </el-menu-item>
|
|
24
|
+ <el-menu-item :index="menuSub.path" @click="jumpRoute(menuSub)">{{
|
|
25
|
+ menuSub.name
|
|
26
|
+ }}</el-menu-item>
|
|
27
|
+ </el-menu-item-group>
|
37
|
28
|
</el-sub-menu>
|
38
|
|
-
|
39
|
|
- <el-menu-item
|
40
|
|
- v-else
|
41
|
|
- :index="item.path"
|
42
|
|
- @mouseenter="
|
43
|
|
- (el) => {
|
44
|
|
- moveToMenu(el, item.icon);
|
45
|
|
- }
|
46
|
|
- "
|
47
|
|
- @mouseleave="
|
48
|
|
- (el) => {
|
49
|
|
- leaveToMenu(el, item.icon);
|
50
|
|
- }
|
51
|
|
- "
|
52
|
|
- @click="jumpModule(item.path)"
|
53
|
|
- >
|
54
|
|
- <img :src="getUrl(item.icon)" alt="" />
|
55
|
|
- <template #title>
|
56
|
|
- <span class="muneName">{{ item.name }}</span>
|
57
|
|
- </template>
|
58
|
|
- </el-menu-item>
|
59
|
29
|
</template>
|
60
|
|
- <slot />
|
61
|
30
|
</el-menu>
|
62
|
31
|
</div>
|
63
|
32
|
</template>
|
64
|
33
|
<script setup>
|
65
|
34
|
import { ref, watch, reactive } from "vue";
|
66
|
35
|
import { useRouter } from "vue-router";
|
67
|
|
-import "@/style/zwgk/menuModule.less";
|
68
|
36
|
|
69
|
37
|
const router = useRouter();
|
70
|
38
|
const activeMenu = ref("zfxxgkzn");
|
71
|
39
|
|
72
|
40
|
const menuList = reactive([
|
73
|
41
|
{
|
|
42
|
+ active: true,
|
74
|
43
|
path: "zfxxgkzn",
|
75
|
44
|
icon: "zfxxgkzn",
|
76
|
45
|
name: "政府信息公开指南",
|
77
|
46
|
},
|
78
|
47
|
{
|
|
48
|
+ active: false,
|
79
|
49
|
path: "zfxxgkzd",
|
80
|
50
|
icon: "zfxxgkzd",
|
81
|
51
|
name: "政府信息公开制度",
|
82
|
52
|
},
|
83
|
53
|
{
|
|
54
|
+ active: false,
|
84
|
55
|
path: "zfxxgknb",
|
85
|
56
|
icon: "zfxxgknb",
|
86
|
57
|
name: "政府信息公开年报",
|
87
|
58
|
},
|
88
|
59
|
{
|
|
60
|
+ active: false,
|
89
|
61
|
path: "fdgknr",
|
90
|
62
|
icon: "fdgknr",
|
91
|
63
|
name: "法定公开内容",
|
|
@@ -125,65 +97,76 @@ const menuList = reactive([
|
125
|
97
|
],
|
126
|
98
|
},
|
127
|
99
|
{
|
|
100
|
+ active: false,
|
128
|
101
|
path: "zcwj",
|
129
|
102
|
icon: "zcwj",
|
130
|
103
|
name: "政策文件",
|
131
|
104
|
},
|
132
|
105
|
{
|
|
106
|
+ active: false,
|
133
|
107
|
path: "zcjd",
|
134
|
108
|
icon: "zcjd",
|
135
|
109
|
name: "政策解读",
|
136
|
110
|
},
|
137
|
111
|
{
|
|
112
|
+ active: false,
|
138
|
113
|
path: "xzgfxwj",
|
139
|
114
|
icon: "xzgfxwj",
|
140
|
115
|
name: "行政规范性文件",
|
141
|
116
|
},
|
142
|
117
|
{
|
|
118
|
+ active: false,
|
143
|
119
|
path: "ysqgk",
|
144
|
120
|
icon: "ysqgk",
|
145
|
121
|
name: "依申请公开",
|
146
|
122
|
},
|
147
|
123
|
{
|
|
124
|
+ active: false,
|
148
|
125
|
path: "zfwzgznb",
|
149
|
126
|
icon: "zfwzgznb",
|
150
|
127
|
name: "政府网站工作年报",
|
151
|
128
|
},
|
152
|
129
|
]);
|
153
|
|
-function jumpModule(path) {
|
154
|
|
- activeMenu.value = path;
|
155
|
|
- router.push("/zwgk/" + path);
|
156
|
|
-}
|
157
|
|
-function getUrl(name) {
|
158
|
|
- if (name == activeMenu.value) {
|
159
|
|
- name = name + "s";
|
160
|
|
- }
|
161
|
|
- return new URL(`../../../assets/hdjl/${name}.png`, import.meta.url).href;
|
162
|
|
-}
|
163
|
|
-// 鼠标移入菜单
|
164
|
|
-function moveToMenu(el, url) {
|
165
|
|
- let urls = url + "s";
|
166
|
|
- // 找到当前菜单项中的 img 元素
|
167
|
|
- let imgElement = el.target.querySelector("img");
|
168
|
|
- if (imgElement) {
|
169
|
|
- imgElement.src = imgElement.src.replace(url, urls);
|
170
|
|
- }
|
|
130
|
+// 路由跳转
|
|
131
|
+function jumpRoute(data) {
|
|
132
|
+ activeMenu.value = data.path;
|
|
133
|
+ router.push("/zwgk/" + data.path);
|
171
|
134
|
}
|
172
|
|
-// 鼠标移出菜单
|
173
|
|
-function leaveToMenu(el, url) {
|
174
|
|
- let urls = url + "s";
|
175
|
|
- // 找到当前菜单项中的 img 元素
|
176
|
|
- let imgElement = el.target.querySelector("img");
|
177
|
|
- if (imgElement) {
|
178
|
|
- imgElement.src = imgElement.src.replace(urls, url);
|
|
135
|
+// 获取图片地址
|
|
136
|
+function getImgUrl(data) {
|
|
137
|
+ let url = "";
|
|
138
|
+ if (data.active) {
|
|
139
|
+ url = data.icon + "s";
|
|
140
|
+ } else {
|
|
141
|
+ url = data.icon;
|
179
|
142
|
}
|
|
143
|
+ return new URL(`../../../assets/hdjl/${url}.png`, import.meta.url).href;
|
180
|
144
|
}
|
181
|
|
-
|
|
145
|
+// 监听 选中的菜单对应的图标高亮
|
|
146
|
+watch(
|
|
147
|
+ () => activeMenu.value,
|
|
148
|
+ (newValue) => {
|
|
149
|
+ let hasSlash = newValue.includes("/");
|
|
150
|
+ let menuPath = hasSlash ? "fdgknr" : newValue;
|
|
151
|
+ menuList.forEach((item) => {
|
|
152
|
+ if (menuPath == item.path) {
|
|
153
|
+ item.active = true;
|
|
154
|
+ } else {
|
|
155
|
+ item.active = false;
|
|
156
|
+ }
|
|
157
|
+ });
|
|
158
|
+ },
|
|
159
|
+ { immediate: true }
|
|
160
|
+);
|
|
161
|
+// 监听路由
|
182
|
162
|
watch(
|
183
|
|
- () => router.currentRoute.value.name,
|
|
163
|
+ () => router.currentRoute.value.path,
|
184
|
164
|
(newValue) => {
|
185
|
|
- activeMenu.value = newValue == "zwgk" ? "zfxxgkzn" : newValue;
|
|
165
|
+ activeMenu.value = newValue.replace("/zwgk/", "");
|
186
|
166
|
},
|
187
|
167
|
{ immediate: true }
|
188
|
168
|
);
|
189
|
169
|
</script>
|
|
170
|
+<style lang="less" scoped>
|
|
171
|
+@import url(@/style/zwgk/menuStyle.less);
|
|
172
|
+</style>
|