const formatAuthData = ({ authData }) => {
const find = (arr, parentId = '') => {
for (let i = 0; i < arr.length; i++) {
if (Array.isArray(arr[i].children) && arr[i].children.length > 0) {
arr[i].id = `${parentId}${i + 1}`
find(arr[i].children, `${parentId}${i + 1}`)
} else {
arr[i].id = `${parentId}${i + 1}`
}
}
}
const authDataCopy = deepClone(authData)
find(authDataCopy)
return authDataCopy
}
data.js:
const router = [
{
title: '首页',
icon: 'home',
className: 'm-sidebar-home',
isVisible: true,
},
{
title: 'xx',
icon: 'base',
isVisible: true,
key: '/sale/index/offline',
children: [
{
title: 'xx',
icon: '',
isVisible: true,
},
{
title: 'xxx',
icon: '',
isVisible: true,
},
]
},
]