| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- export const constantRoutes = [
- {
- path: '/login',
- meta: { title: '登录' },
- type: 'sys',
- label: '',
- icon: 'el-icon-star-on',
- component: () => import('@/views/login/index.vue'),
- hidden: true
- },
- {
- path: '/gislogin',
- meta: { title: '登录' },
- type: 'sys',
- label: '',
- icon: 'el-icon-star-on',
- component: () => import('@/views/gislogin/index.vue'),
- hidden: true
- },
- {
- path: '/404',
- hidden: true,
- component: () => import('@/views/404.vue')
- }
- ]
- // 404
- export const ERROR = [
- {
- path: '*',
- redirect: '/404',
- hidden: true
- }
- ]
- import _import from './_import' // 获取组件的方法
- /**
- * 生成路由
- * @param {Array} routerlist 格式化路由
- * @returns
- */
- export function packageRouter(routerlist) {
- function extractIcon(icon) {
- let result
- if (icon !== null && icon) {
- result = icon.substr(9)
- } else result = ''
- return `iconfont ${result}`
- }
- const router: any[] = []
- routerlist.forEach((e) => {
- if (e.statusFlag == '1') {
- const meta = () => {
- let temp = {}
- try {
- temp = JSON.parse(e.meta || '{}')
- } catch (error) {
- console.log({ meta: e.meta, error })
- }
- return temp
- }
- let e_new = {
- path: e.path || '',
- name: e.name,
- id: e.pathId,
- type: e.type,
- label: e.label,
- icon: extractIcon(e.icon),
- widgetid: e.widgetid || '',
- component: _import(e.component),
- meta: meta(),
- parentPathid: e.parentPathid || ''
- }
- if (e.childrens && e.childrens.length > 0) {
- e_new = Object.assign({}, e_new, {
- children: packageRouter(e.childrens)
- })
- }
- if (e.redirect) {
- e_new = Object.assign({}, e_new, { redirect: e.redirect })
- }
- if (e.path === '/map') {
- e_new = Object.assign({}, e_new, { hidden: true })
- }
- router.push(e_new)
- }
- })
- return router
- }
|