路由菜单根据路径匹配显示
Showing
3 changed files
with
85 additions
and
120 deletions
| ... | @@ -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 | { | 107 | ...AssetIndex, |
| 108 | meta:{ | 108 | ...DataAssess, |
| 109 | title: '数据资产看板', | 109 | ...DataAssetRegistry, |
| 110 | }, | 110 | ...DataEntry, |
| 111 | children: [ | 111 | ...SecurityMenu, |
| 112 | ...AssetIndex, | 112 | ...DataMeta, |
| 113 | ], | 113 | ...DataQuality, |
| 114 | }, | 114 | ...DataInventory |
| 115 | { | ||
| 116 | meta: { | ||
| 117 | title: '数据产品管理', | ||
| 118 | }, | ||
| 119 | children: [ | ||
| 120 | ...DataAssess, | ||
| 121 | ], | ||
| 122 | }, | ||
| 123 | { | ||
| 124 | meta: { | ||
| 125 | title: '数据资产登记', | ||
| 126 | }, | ||
| 127 | children: [ | ||
| 128 | ...DataAssetRegistry, | ||
| 129 | ], | ||
| 130 | }, | ||
| 131 | { | ||
| 132 | meta: { | ||
| 133 | title: '数据资产入表', | ||
| 134 | }, | ||
| 135 | children: [ | ||
| 136 | ...DataEntry, | ||
| 137 | ], | ||
| 138 | }, | ||
| 139 | { | ||
| 140 | meta: { | ||
| 141 | title: '法律风险意见', | ||
| 142 | }, | ||
| 143 | children: [ | ||
| 144 | ...SecurityMenu, | ||
| 145 | ], | ||
| 146 | }, | ||
| 147 | { | ||
| 148 | meta: { | ||
| 149 | title: '元数据', | ||
| 150 | }, | ||
| 151 | children: [ | ||
| 152 | ...DataMeta, | ||
| 153 | ], | ||
| 154 | }, | ||
| 155 | { | ||
| 156 | meta: { | ||
| 157 | title: '数据质量', | ||
| 158 | }, | ||
| 159 | children: [ | ||
| 160 | ...DataQuality, | ||
| 161 | ], | ||
| 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[] | 94 | tmpRoutes.map((v) => { |
| 96 | tmpRoutes.map((v) => { | 95 | if (!v.meta) { |
| 97 | if (!v.meta) { | 96 | v.meta = {} |
| 98 | v.meta = {} | 97 | } |
| 99 | } | 98 | v.meta.auth = v.meta?.auth |
| 100 | v.meta.auth = item.meta?.auth ?? v.meta?.auth | 99 | return v |
| 101 | return v | ||
| 102 | }) | ||
| 103 | returnRoutes.push(...tmpRoutes) | ||
| 104 | }) | 100 | }) |
| 101 | returnRoutes.push(...tmpRoutes) | ||
| 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 | } | ... | ... |
| ... | @@ -224,45 +224,49 @@ const useUserStore = defineStore( | ... | @@ -224,45 +224,49 @@ const useUserStore = defineStore( |
| 224 | async function setTabbarInfo(list) { | 224 | async function setTabbarInfo(list) { |
| 225 | let obj: any = {} | 225 | let obj: any = {} |
| 226 | list.map(item => { | 226 | list.map(item => { |
| 227 | let mark = '' | 227 | let mark = item.path.split('/')[1]; |
| 228 | if (item.meta.title == '数据标准') { | ||
| 229 | mark = 'data-standards' | ||
| 230 | } else if (item.meta.title == '元数据') { | ||
| 231 | mark = 'data-meta' | ||
| 232 | } else if (item.meta.title == '数据目录') { | ||
| 233 | mark = 'data-catalog' | ||
| 234 | } else if (item.meta.title == '数据同步') { | ||
| 235 | mark = 'data-sync' | ||
| 236 | } else if (item.meta.title == '数据质量') { | ||
| 237 | mark = 'data-quality' | ||
| 238 | } else if (item.meta.title == '数据盘点') { | ||
| 239 | mark = 'data-inventory' | ||
| 240 | } else if (item.meta.title == '数据资产看板') { | ||
| 241 | mark = 'data-asset-index' | ||
| 242 | } else if (item.meta.title == '数据资产登记') { | ||
| 243 | mark = 'data-asset-register' | ||
| 244 | } else if (item.meta.title == '数据产品管理') { | ||
| 245 | mark = 'data-asset' | ||
| 246 | } else if (item.meta.title == '入表交易融资') { | ||
| 247 | mark = 'data-transaction' | ||
| 248 | } else if (item.meta.title == '入表融资指南') { | ||
| 249 | mark = 'data-guide' | ||
| 250 | } else if (item.meta.title == '入表服务管理') { | ||
| 251 | mark = 'data-entry' | ||
| 252 | } else if (item.meta.title == '数据资产入表') { | ||
| 253 | mark = 'data-entry' | ||
| 254 | } else if (item.meta.title == '法律风险意见') { | ||
| 255 | mark = 'data-security' | ||
| 256 | } else if (item.meta.title == '金融服务') { | ||
| 257 | mark = 'data-finance' | ||
| 258 | } else if (item.meta.title == '系统管理') { | ||
| 259 | mark = 'system-manage' | ||
| 260 | } else { | ||
| 261 | mark = 'app-scenes' | ||
| 262 | } | ||
| 263 | obj.activePath = '' | 228 | obj.activePath = '' |
| 264 | obj.tabbar = [] | 229 | obj.tabbar = [] |
| 265 | tabbarMap.value[mark] = obj | 230 | tabbarMap.value[mark] = obj |
| 231 | // let mark = '' | ||
| 232 | // if (item.meta.title == '数据标准') { | ||
| 233 | // mark = 'data-standards' | ||
| 234 | // } else if (item.meta.title == '元数据') { | ||
| 235 | // mark = 'data-meta' | ||
| 236 | // } else if (item.meta.title == '数据目录') { | ||
| 237 | // mark = 'data-catalog' | ||
| 238 | // } else if (item.meta.title == '数据同步') { | ||
| 239 | // mark = 'data-sync' | ||
| 240 | // } else if (item.meta.title == '数据质量') { | ||
| 241 | // mark = 'data-quality' | ||
| 242 | // } else if (item.meta.title == '数据盘点') { | ||
| 243 | // mark = 'data-inventory' | ||
| 244 | // } else if (item.meta.title == '数据资产看板') { | ||
| 245 | // mark = 'data-asset-index' | ||
| 246 | // } else if (item.meta.title == '数据资产登记') { | ||
| 247 | // mark = 'data-asset-register' | ||
| 248 | // } else if (item.meta.title == '数据产品管理') { | ||
| 249 | // mark = 'data-asset' | ||
| 250 | // } else if (item.meta.title == '入表交易融资') { | ||
| 251 | // mark = 'data-transaction' | ||
| 252 | // } else if (item.meta.title == '入表融资指南') { | ||
| 253 | // mark = 'data-guide' | ||
| 254 | // } else if (item.meta.title == '入表服务管理') { | ||
| 255 | // mark = 'data-entry' | ||
| 256 | // } else if (item.meta.title == '数据资产入表') { | ||
| 257 | // mark = 'data-entry' | ||
| 258 | // } else if (item.meta.title == '法律风险意见') { | ||
| 259 | // mark = 'data-security' | ||
| 260 | // } else if (item.meta.title == '金融服务') { | ||
| 261 | // mark = 'data-finance' | ||
| 262 | // } else if (item.meta.title == '系统管理') { | ||
| 263 | // mark = 'system-manage' | ||
| 264 | // } else { | ||
| 265 | // mark = 'app-scenes' | ||
| 266 | // } | ||
| 267 | // obj.activePath = '' | ||
| 268 | // obj.tabbar = [] | ||
| 269 | // tabbarMap.value[mark] = obj | ||
| 266 | }) | 270 | }) |
| 267 | } | 271 | } |
| 268 | function setTabbar(val: any = null) { | 272 | function setTabbar(val: any = null) { | ... | ... |
-
Please register or sign in to post a comment