派生自 wuyushui/SewerAndRainNetwork

YANGDL
2021-01-05 f3bde7e1116787ac34da4a2974374b4915e5bd54
优化逻辑
1个文件已添加
3个文件已修改
50 ■■■■ 已修改文件
src/main.js 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.js 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/map.js 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/routes.js 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main.js
@@ -11,6 +11,7 @@
Vue.config.productionTip = false
Vue.use(ElementUI, { size: 'small' })
Vue.prototype.$cancels = []
// 注册指令
// registerDirectives(Vue)
src/router/index.js
@@ -11,5 +11,21 @@
  mode: routeMode || 'hash',
  routes: routes
})
router.beforeEach((to, from, next) => {
  Vue.prototype.$cancels.forEach((cancel) => {
    cancel()
  })
  Vue.prototype.$cancels = []
  // 不需要登录认证的路由
  if (Object.hasOwnProperty.call(to.meta, 'noLoginIdentify') && to.meta.noLoginIdentify) {
    next()
    return
  }
  next()
})
router.beforeResolve((to, from, next) => {
  next()
})
router.afterEach((to, from) => {
})
export default router
src/router/map.js
New file
@@ -0,0 +1,18 @@
/**
 * meta可配置的参数:
 * meta: {
 *  title: { String } 显示在侧边栏、面包屑和标签栏的文字
 *  hideBread: (false) 设为true后此级路由将不会出现在面包屑中
 *  hideMenu: (false) 设为true后在左侧菜单不会显示该页面选项
 *  notCache: (false) 设为true后页面在切换标签后不会缓存,如果需要缓存,无需设置这个字段,而且需要设置页面组件name属性和路由配置的name一致
 *  access: (null) 可访问该页面的权限数组,当前路由设置的权限会影响子路由
 * }
 */
const MapTemplate = (r) => require.ensure([], () => r(require('../views/MapTemplate')), 'frame')
// const MapHomeMapTalks = r => require.ensure([], () => r(require('../views/map/MapHome-maptalks')), 'web')
const routes = [
  { path: '/mapTemplate', name: 'MapTemplate', meta: { statusBgc: 0 }, component: MapTemplate }
]
// 所有上面定义的路由都要写在下面的routes里
export const mapRoutes = routes
src/router/routes.js
@@ -8,24 +8,18 @@
 *  access: (null) 可访问该页面的权限数组,当前路由设置的权限会影响子路由
 * }
 */
import { mapRoutes } from '@router/map'
// 默认跳转路由
import PipeLineIndex from '../views/baseInfoMgr/pipeline/PipeLineIndex'
import MapTemplate from '../views/MapTemplate'
// 应用业务相关路由,挂载menu上的page
export const routes = [{
const mainRoutes = [{
  path: '/',
  name: 'Main',
  component: MapTemplate,
  redirect: '/home',
  redirect: '/mapTemplate',
  children: [{
    path: 'home',
    name: 'Home',
    meta: {
      title: '首页'
    },
    component: MapTemplate
  }, {
    path: 'baseInfoMgr/pipeLine',
    name: 'baseInfoMgr',
    component: PipeLineIndex,
@@ -34,3 +28,4 @@
    }
  }]
}]
export const routes = [...mainRoutes, ...mapRoutes]