研发图纸文件管理系统-前端项目
chenghongxing
2020-09-03 69b514ee10ff2118dc0089bad560db1910fcd960
chore: optimize the code of routerUtil.js
1个文件已修改
9 ■■■■■ 已修改文件
src/utils/routerUtil.js 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/routerUtil.js
@@ -156,10 +156,11 @@
function formatAuthority(routes, pAuthorities = []) {
  routes.forEach(route => {
    const meta = route.meta
    const defaultAuthority = pAuthorities[pAuthorities.length - 1] || {permission: '*'}
    if (meta) {
      let authority = {}
      if (!meta.authority) {
        authority = pAuthorities.length > 0 ? pAuthorities[pAuthorities.length - 1] : {permission: '*'}
        authority = defaultAuthority
      }else if (typeof meta.authority === 'string') {
        authority.permission = meta.authority
      } else if (typeof meta.authority === 'object') {
@@ -169,14 +170,12 @@
          authority.role = [role]
        }
        if (!authority.permission && !authority.role) {
          authority = pAuthorities.length > 0 ? pAuthorities[pAuthorities.length - 1] : {permission: '*'}
          authority = defaultAuthority
        }
      } else {
        console.log(typeof meta.authority)
      }
      meta.authority = authority
    } else {
      const authority = pAuthorities.length > 0 ? pAuthorities[pAuthorities.length - 1] : {permission: '*'}
      const authority = defaultAuthority
      route.meta = {authority}
    }
    route.meta.pAuthorities = pAuthorities