Merge pull request 'refactor(permission): 优化面包屑控制逻辑' (#1006) from master into prod
Reviewed-on: http://git.feashow.cn/clay/mosr-web/pulls/1006
This commit is contained in:
@@ -37,9 +37,11 @@ export const usePermisstionStroe = defineStore('permisstion', () => {
|
||||
if (res.code === 1000) {
|
||||
const sRouter = JSON.parse(JSON.stringify(res.data))
|
||||
const mData = JSON.parse(JSON.stringify(res.data))
|
||||
// console.log(JSON.parse(JSON.stringify(sRouter)), 'sRouter');
|
||||
const firstFormat = setRouterLevel(JSON.parse(JSON.stringify(sRouter)))
|
||||
|
||||
console.log(firstFormat, 'firstFormat');
|
||||
asyncRouters.value = formatAsyncRouters(JSON.parse(JSON.stringify(firstFormat)))
|
||||
console.log('asyncRouters.value',firstFormat);
|
||||
menuList.value = [...menuList.value, ...generateMenu(mData)]
|
||||
addAsyncRouters(asyncRouters.value)
|
||||
isLoadRoutes.value = false
|
||||
@@ -52,16 +54,23 @@ export const usePermisstionStroe = defineStore('permisstion', () => {
|
||||
}
|
||||
|
||||
const setRouterLevel = (routers) => {
|
||||
|
||||
return routers.filter(item=>{
|
||||
if(item.component === 'Layout') {
|
||||
if(item.children) {
|
||||
// console.log("🚀 ~ file: item.children ", item.children )
|
||||
item.children.forEach(v=>{
|
||||
if(v.children) {
|
||||
slRouters.value = [...toRaw(slRouters.value), ...v.children]
|
||||
delete v.children
|
||||
// console.log("🚀 ~ file:item.children",item.children)
|
||||
// console.log("🚀 ~ file: v.children ", v.children )
|
||||
// slRouters.value = [ ...toRaw(v.children)]
|
||||
// delete v.children
|
||||
// slRouters.value = [ ...v.children]
|
||||
// return v.children
|
||||
item.children = [...item.children,...v.children]
|
||||
}
|
||||
})
|
||||
item.children = [...item.children, ...toRaw(slRouters.value)]
|
||||
|
||||
}
|
||||
}
|
||||
return true
|
||||
@@ -81,6 +90,7 @@ export const usePermisstionStroe = defineStore('permisstion', () => {
|
||||
}
|
||||
if (route.children !== null && route.children && route.children.length !== 0) {
|
||||
route.children = formatAsyncRouters(route.children)
|
||||
|
||||
}
|
||||
return true
|
||||
})
|
||||
@@ -90,6 +100,8 @@ export const usePermisstionStroe = defineStore('permisstion', () => {
|
||||
routers.forEach(route => {
|
||||
router.addRoute(route)
|
||||
})
|
||||
console.log("🚀 ~ file: ", routers)
|
||||
|
||||
}
|
||||
|
||||
const generateMenu = (routes) => {
|
||||
|
||||
Reference in New Issue
Block a user