| | |
| | | params: data |
| | | }) |
| | | } |
| | | export function LoginMenu(data) { |
| | | return request({ |
| | | url: 'Login/LoginMenu', |
| | | method: 'get', |
| | | params: data |
| | | }) |
| | | } |
| | | |
| | | export function getInfo(token) { |
| | | return request({ |
| | |
| | | import { Message } from 'element-ui' |
| | | import NProgress from 'nprogress' // progress bar |
| | | import 'nprogress/nprogress.css' // progress bar style |
| | | import { getToken } from '@/utils/auth' // get token from cookie |
| | | import { getCookie, getToken } from '@/utils/auth' // get token from cookie |
| | | import getPageTitle from '@/utils/get-page-title' |
| | | |
| | | NProgress.configure({ showSpinner: false }) // NProgress Configuration |
| | |
| | | document.title = getPageTitle(to.meta.title) |
| | | |
| | | // determine whether the user has logged in |
| | | const hasToken = getToken() |
| | | |
| | | // const hasToken = getToken() |
| | | const hasToken = getCookie('admin') |
| | | if (hasToken) { |
| | | if (to.path === '/login') { |
| | | // if is logged in, redirect to the home page |
| | |
| | | // next() |
| | | |
| | | // æåinfo |
| | | const info = await store.dispatch('user/getInfo') |
| | | // const info = await store.dispatch('user/getInfo') |
| | | // çæå¯è®¿é®çè·¯ç±è¡¨ |
| | | await store.dispatch('permission/generateRoutes', info) |
| | | // await store.dispatch('permission/generateRoutes') |
| | | |
| | | // å¨ææ·»å å¯è®¿é®è·¯ç±è¡¨ |
| | | router.addRoutes(store.getters.addRouters) |
| | | // router.addRoutes(store.getters.addRouters) |
| | | |
| | | // hackæ¹æ³ ç¡®ä¿addRoutes已宿 |
| | | next({ ...to, replace: true }) |
| | | // next({ ...to, replace: true }) |
| | | |
| | | // console.log(store.getters.addRouters, 1) |
| | | // const s = store.getters.addRouters |
| | | // router.addRoutes(s) |
| | | // if (s) { |
| | | // console.log(s) |
| | | // } |
| | | next() |
| | | // next({ ...to, replace: true }) |
| | | } catch (error) { |
| | | // remove token and go to login page to re-login |
| | | await store.dispatch('user/resetToken') |
| | |
| | | path: '/404', |
| | | component: () => import('@/views/404'), |
| | | hidden: true |
| | | }, |
| | | { |
| | | path: '/redirect', |
| | | component: Layout, |
| | | hidden: true, |
| | | children: [ |
| | | { |
| | | path: '/redirect/:path(.*)', |
| | | component: () => import('@/views/redirect/index') |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | path: '/', |
| | | component: Layout, |
| | | redirect: '/index', |
| | | children: [{ |
| | | path: 'index', |
| | | name: 'index', |
| | | component: () => import('@/views/xtsy/index'), |
| | | meta: { title: 'ç³»ç»é¦é¡µ', icon: 'dashboard' } |
| | | }] |
| | | }, |
| | | { |
| | | path: '/jcsz', |
| | | component: Layout, |
| | | redirect: '/jcsz/zzjg', |
| | | name: 'jcsz', |
| | | meta: { title: 'åºç¡è®¾ç½®', icon: 'el-icon-setting' }, |
| | | children: [ |
| | | { |
| | | path: 'zzjg', |
| | | name: 'Table', |
| | | component: () => import('@/views/jcsz/zzjg'), |
| | | meta: { title: 'ç»ç»æ¶æ', icon: '' } |
| | | }, { |
| | | path: 'jsqd', |
| | | name: 'jsqd', |
| | | component: () => import('@/views/jcsz/jsqd'), |
| | | meta: { title: 'è§è²æ¸
å', icon: '' } |
| | | }, { |
| | | path: 'yhqd', |
| | | name: 'yhqd', |
| | | component: () => import('@/views/jcsz/yhqd'), |
| | | meta: { title: 'ç¨æ·æ¸
å', icon: '' } |
| | | }, { |
| | | path: 'wldw', |
| | | name: 'wldw', |
| | | component: () => import('@/views/jcsz/wldw'), |
| | | meta: { title: '徿¥åä½', icon: '' } |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | path: '/zzmx', |
| | | component: Layout, |
| | | redirect: '/zzmx/gylx', |
| | | name: 'zzmx', |
| | | meta: { title: 'å¶é 模å', icon: 'el-icon-s-help' }, |
| | | children: [ |
| | | { |
| | | path: 'gylx', |
| | | name: 'gylx', |
| | | component: () => import('@/views/zzmx/gylx'), |
| | | meta: { title: 'å
¬ç路线', icon: 'table' } |
| | | }, |
| | | { |
| | | path: 'jpgj', |
| | | name: 'jpgj', |
| | | component: () => import('@/views/zzmx/jpgj'), |
| | | meta: { title: 'èæå·¥ä»·', icon: 'tree' } |
| | | } |
| | | ] |
| | | } |
| | | ] |
| | | |
| | |
| | | // '0'代表false,'1'代表true |
| | | const routes = [ |
| | | { |
| | | path: '/redirect', |
| | | component: 'Layout', |
| | | hidden: '1', |
| | | children: [ |
| | | { |
| | | path: '/redirect/:path(.*)', |
| | | component: '/redirect/index' |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | path: '/', |
| | | component: 'Layout', |
| | | redirect: '/index', |
| | |
| | | component: '/xtsy/index', |
| | | meta: { title: 'ç³»ç»é¦é¡µ', icon: 'el-icon-house', affix: '1' } |
| | | }] |
| | | }, |
| | | { |
| | | path: '/redirect', |
| | | component: 'Layout', |
| | | hidden: '1', |
| | | children: [ |
| | | { |
| | | path: '/redirect/:path(.*)', |
| | | component: '/redirect/index' |
| | | } |
| | | ] |
| | | }, |
| | | { |
| | | path: '/jcsz', |
| | |
| | | asyncRoutes.push({ path: '*', redirect: '/404', hidden: true }) |
| | | commit('SET_ROUTES', asyncRoutes) |
| | | resolve(asyncRoutes) |
| | | console.log(asyncRoutes, 1) |
| | | }) |
| | | } |
| | | } |