965e1121 by lihua

路由菜单根据路径匹配显示

1 parent 0fcbaee9
...@@ -103,70 +103,15 @@ const systemRoutes: RouteRecordRaw[] = [ ...@@ -103,70 +103,15 @@ const systemRoutes: RouteRecordRaw[] = [
103 ] 103 ]
104 104
105 // 动态路由(异步路由、导航栏路由) 105 // 动态路由(异步路由、导航栏路由)
106 const asyncRoutes: Route.recordMainRaw[] = [ 106 const asyncRoutes: RouteRecordRaw[] = [
107 {
108 meta:{
109 title: '数据资产看板',
110 },
111 children: [
112 ...AssetIndex, 107 ...AssetIndex,
113 ],
114 },
115 {
116 meta: {
117 title: '数据产品管理',
118 },
119 children: [
120 ...DataAssess, 108 ...DataAssess,
121 ],
122 },
123 {
124 meta: {
125 title: '数据资产登记',
126 },
127 children: [
128 ...DataAssetRegistry, 109 ...DataAssetRegistry,
129 ],
130 },
131 {
132 meta: {
133 title: '数据资产入表',
134 },
135 children: [
136 ...DataEntry, 110 ...DataEntry,
137 ],
138 },
139 {
140 meta: {
141 title: '法律风险意见',
142 },
143 children: [
144 ...SecurityMenu, 111 ...SecurityMenu,
145 ],
146 },
147 {
148 meta: {
149 title: '元数据',
150 },
151 children: [
152 ...DataMeta, 112 ...DataMeta,
153 ],
154 },
155 {
156 meta: {
157 title: '数据质量',
158 },
159 children: [
160 ...DataQuality, 113 ...DataQuality,
161 ], 114 ...DataInventory
162 }, {
163 meta: {
164 title: '数据盘点',
165 },
166 children: [
167 ...DataInventory,
168 ],
169 },
170 ] 115 ]
171 116
172 const constantRoutesByFilesystem = generatedRoutes.filter((item) => { 117 const constantRoutesByFilesystem = generatedRoutes.filter((item) => {
......
...@@ -3,7 +3,6 @@ import type { RouteMeta, RouteRecordRaw } from 'vue-router' ...@@ -3,7 +3,6 @@ import type { RouteMeta, RouteRecordRaw } from 'vue-router'
3 import useSettingsStore from './settings' 3 import useSettingsStore from './settings'
4 import useUserStore from './user' 4 import useUserStore from './user'
5 import { resolveRoutePath } from '@/utils' 5 import { resolveRoutePath } from '@/utils'
6 import { getImageContent } from "@/api/modules/queryService";
7 import {createSVG } from "@/utils/common" 6 import {createSVG } from "@/utils/common"
8 import { systemRoutes } from '@/router/routes' 7 import { systemRoutes } from '@/router/routes'
9 import apiApp from '@/api/modules/app' 8 import apiApp from '@/api/modules/app'
...@@ -91,17 +90,15 @@ const useRouteStore = defineStore( ...@@ -91,17 +90,15 @@ const useRouteStore = defineStore(
91 const returnRoutes: RouteRecordRaw[] = [] 90 const returnRoutes: RouteRecordRaw[] = []
92 if (routesRaw.value) { 91 if (routesRaw.value) {
93 if (settingsStore.settings.app.routeBaseOn !== 'filesystem') { 92 if (settingsStore.settings.app.routeBaseOn !== 'filesystem') {
94 routesRaw.value.forEach((item) => { 93 const tmpRoutes = cloneDeep(routesRaw.value) as RouteRecordRaw[]
95 const tmpRoutes = cloneDeep(item.children) as RouteRecordRaw[]
96 tmpRoutes.map((v) => { 94 tmpRoutes.map((v) => {
97 if (!v.meta) { 95 if (!v.meta) {
98 v.meta = {} 96 v.meta = {}
99 } 97 }
100 v.meta.auth = item.meta?.auth ?? v.meta?.auth 98 v.meta.auth = v.meta?.auth
101 return v 99 return v
102 }) 100 })
103 returnRoutes.push(...tmpRoutes) 101 returnRoutes.push(...tmpRoutes)
104 })
105 returnRoutes.forEach(item => flatAsyncRoutes(item)) 102 returnRoutes.forEach(item => flatAsyncRoutes(item))
106 } 103 }
107 else { 104 else {
...@@ -155,17 +152,27 @@ const useRouteStore = defineStore( ...@@ -155,17 +152,27 @@ const useRouteStore = defineStore(
155 if (p && p.productRoute) { 152 if (p && p.productRoute) {
156 path = p.productRoute + p.path; 153 path = p.productRoute + p.path;
157 } 154 }
155 m.meta = {
156 title: m.productName || m.menuName
157 };
158 } 158 }
159 r = routes.find((route: any) => route.path === path || route.path === m.path || `/${route.path}` === m.path); 159 r = routes.find((route: any) => route.path === path || route.path === m.path || `/${route.path}` === m.path);
160 if(r && m.icon && m.icon !== "{}") { 160 if(r && m.icon && m.icon !== "{}") {
161 r.meta.title = m.menuName || r.meta.title; 161
162 r.meta.icon = m.icon 162 r.meta.icon = m.icon
163 r.meta.isEle = true 163 r.meta.isEle = true
164 } 164 }
165 } else { 165 } else {
166 r = routes.find((route: any) => route.meta.title === m.productName); 166 // r = routes.find((route: any) => route.meta.title === m.productName);
167 if(r && m.icon && m.icon !== "{}") { 167 // if(m.icon && m.icon !== "{}") {
168 r.meta.title = m.menuName || r.meta.title; 168 // r.meta.icon = m.icon
169 // r.meta.isEle = true
170 // }
171 m.meta = {
172 title: m.productName
173 };
174 r = m;
175 if(m.icon && m.icon !== "{}") {
169 r.meta.icon = m.icon 176 r.meta.icon = m.icon
170 r.meta.isEle = true 177 r.meta.isEle = true
171 } 178 }
...@@ -173,25 +180,34 @@ const useRouteStore = defineStore( ...@@ -173,25 +180,34 @@ const useRouteStore = defineStore(
173 if (r && hasPermission(permissions, r)) { 180 if (r && hasPermission(permissions, r)) {
174 const tmpRoute = cloneDeep(r); 181 const tmpRoute = cloneDeep(r);
175 if (m.menuType === 'C') { 182 if (m.menuType === 'C') {
176 tmpRoute.meta.title = m.menuName; 183 tmpRoute.meta.title = m.productName ?? m.menuName;
177 } 184 }
178 if (tmpRoute.children) { 185 let children = m.productName ? m.menuList : m.children;
186 if (children) {
179 if (m.menuType === 'C') { 187 if (m.menuType === 'C') {
180 tmpRoute.children = tmpRoute.children.filter(child => { 188 let cc: any = [];
189 children.forEach(child => {
181 if (!child.path) { 190 if (!child.path) {
182 return true; 191 return true;
183 } 192 }
184 if (child.sidebar === false) { 193 if (child.sidebar === false) {
185 return true; 194 return true;
186 } 195 }
187 return filterAsyncRoutes([child], permissions, m.children || [], parentPath + m.path)?.length > 0; 196 let result = filterAsyncRoutes(tmpRoute.children || [], permissions, [child], parentPath + m.path);
197 if (result.length > 0) {
198 cc.push(result[0]);
199 }
188 }); 200 });
201 tmpRoute.children = cc;
189 } else { 202 } else {
190 tmpRoute.children = filterAsyncRoutes(tmpRoute.children, permissions, (m.productName ? m.menuList : m.children) || [], m.productRoute ?? "") 203 tmpRoute.children = filterAsyncRoutes(routes, permissions, (m.productName ? m.menuList : m.children) || [], m.productRoute ?? "")
191 } 204 }
192 tmpRoute.children.length && res.push(tmpRoute) 205 tmpRoute.children.length && res.push(tmpRoute)
193 } 206 }
194 else { 207 else {
208 if (m.menuType === 'C' && tmpRoute.children?.length) {
209 tmpRoute.children = tmpRoute.children?.filter(t => t.path == '') || [];
210 }
195 res.push(tmpRoute) 211 res.push(tmpRoute)
196 } 212 }
197 } 213 }
......
...@@ -225,45 +225,49 @@ const useUserStore = defineStore( ...@@ -225,45 +225,49 @@ const useUserStore = defineStore(
225 async function setTabbarInfo(list) { 225 async function setTabbarInfo(list) {
226 let obj: any = {} 226 let obj: any = {}
227 list.map(item => { 227 list.map(item => {
228 let mark = '' 228 let mark = item.path.split('/')[1];
229 if (item.meta.title == '数据标准') {
230 mark = 'data-standards'
231 } else if (item.meta.title == '元数据') {
232 mark = 'data-meta'
233 } else if (item.meta.title == '数据目录') {
234 mark = 'data-catalog'
235 } else if (item.meta.title == '数据同步') {
236 mark = 'data-sync'
237 } else if (item.meta.title == '数据质量') {
238 mark = 'data-quality'
239 } else if (item.meta.title == '数据盘点') {
240 mark = 'data-inventory'
241 } else if (item.meta.title == '数据资产看板') {
242 mark = 'data-asset-index'
243 } else if (item.meta.title == '数据资产登记') {
244 mark = 'data-asset-register'
245 } else if (item.meta.title == '数据产品管理') {
246 mark = 'data-asset'
247 } else if (item.meta.title == '入表交易融资') {
248 mark = 'data-transaction'
249 } else if (item.meta.title == '入表融资指南') {
250 mark = 'data-guide'
251 } else if (item.meta.title == '入表服务管理') {
252 mark = 'data-entry'
253 } else if (item.meta.title == '数据资产入表') {
254 mark = 'data-entry'
255 } else if (item.meta.title == '法律风险意见') {
256 mark = 'data-security'
257 } else if (item.meta.title == '金融服务') {
258 mark = 'data-finance'
259 } else if (item.meta.title == '系统管理') {
260 mark = 'system-manage'
261 } else {
262 mark = 'app-scenes'
263 }
264 obj.activePath = '' 229 obj.activePath = ''
265 obj.tabbar = [] 230 obj.tabbar = []
266 tabbarMap.value[mark] = obj 231 tabbarMap.value[mark] = obj
232 // let mark = ''
233 // if (item.meta.title == '数据标准') {
234 // mark = 'data-standards'
235 // } else if (item.meta.title == '元数据') {
236 // mark = 'data-meta'
237 // } else if (item.meta.title == '数据目录') {
238 // mark = 'data-catalog'
239 // } else if (item.meta.title == '数据同步') {
240 // mark = 'data-sync'
241 // } else if (item.meta.title == '数据质量') {
242 // mark = 'data-quality'
243 // } else if (item.meta.title == '数据盘点') {
244 // mark = 'data-inventory'
245 // } else if (item.meta.title == '数据资产看板') {
246 // mark = 'data-asset-index'
247 // } else if (item.meta.title == '数据资产登记') {
248 // mark = 'data-asset-register'
249 // } else if (item.meta.title == '数据产品管理') {
250 // mark = 'data-asset'
251 // } else if (item.meta.title == '入表交易融资') {
252 // mark = 'data-transaction'
253 // } else if (item.meta.title == '入表融资指南') {
254 // mark = 'data-guide'
255 // } else if (item.meta.title == '入表服务管理') {
256 // mark = 'data-entry'
257 // } else if (item.meta.title == '数据资产入表') {
258 // mark = 'data-entry'
259 // } else if (item.meta.title == '法律风险意见') {
260 // mark = 'data-security'
261 // } else if (item.meta.title == '金融服务') {
262 // mark = 'data-finance'
263 // } else if (item.meta.title == '系统管理') {
264 // mark = 'system-manage'
265 // } else {
266 // mark = 'app-scenes'
267 // }
268 // obj.activePath = ''
269 // obj.tabbar = []
270 // tabbarMap.value[mark] = obj
267 }) 271 })
268 } 272 }
269 function setTabbar(val: any = null) { 273 function setTabbar(val: any = null) {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!