routes.js 912 Bytes
import { mobilePages } from './mobile'

const keepAlives = []

// 合并所有页面配置
const pages = { ...mobilePages }

let routes = [
  {
    path: '/',
    redirect: '/mobile' // 默认重定向到 mobile,或者根据需求改为其他
  }
]

Object.keys(pages).map(parent => {
  pages[parent].map(val => {
    let childrenPath = `${parent}/${val.name}`
    let { meta } = val
    const path = val.path ? `/${val.path}` : `/${val.name == 'index' ? parent : childrenPath}`
    const name = val.name == 'index' ? parent : val.name
    if (meta && meta.keepAlive) keepAlives.push(name)
    let componentName =`${val.path ? val.path : childrenPath}`
    let route = {
      component: resolve => require([`views/${componentName}.vue`], resolve),
      path,
      name,
      meta
    }
    routes.push(route)
  })
})
export const keeps = keepAlives

export default routes