config.js 585 字节
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
export const uniConfig = Object.create(null)
export const uniRoutes = []

function parseRoutes (config) {
  uniRoutes.length = 0
  /* eslint-disable no-mixed-operators */
  const tabBarList = (config.tabBar && config.tabBar.list || []).map(item => item.pagePath)

  Object.keys(config.page).forEach(function (pagePath) {
    uniRoutes.push({
      path: '/' + pagePath,
      meta: {
        isTabBar: tabBarList.indexOf(pagePath) !== -1
      }
    })
  })
}

export function registerConfig (config) {
  Object.assign(uniConfig, config)
  parseRoutes(uniConfig)
}