12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import Vue from 'vue'
- import router from './router'
- import store from './store'
- import NProgress from 'nprogress'
- import 'nprogress/nprogress.css'
- import notification from 'ant-design-vue/es/notification'
- import {
- ACCESS_TOKEN,
- INDEX_MAIN_PAGE_PATH,
- UI_CACHE_DB_DICT_DATA,
- USER_INFO,
- USER_NAME
- } from '@/store/mutation-types'
- import {
- generateIndexRouter,
- welcome
- } from '@/utils/util'
- NProgress.configure({
- showSpinner: false
- })
- const whiteList = ['/user/login', '/user/register', '/user/register-result', '/user/alteration', '/FocusWarningPage', '/drillingRisk']
- if (process.env.VUE_APP_IFRAME_CHECK === 'TRUE') {
- whiteList.push('/top')
- }
- function initRouter() {
- router.beforeEach((to, from, next) => {
- NProgress.start()
- if (Vue.ls.get(ACCESS_TOKEN)) {
-
- if (to.path === '/user/login') {
- next({
- path: INDEX_MAIN_PAGE_PATH
- })
- NProgress.done()
- } else {
- if (false && store.getters.permissionList.length === 0) {} else {
- next()
- }
- }
- } else {
- if (whiteList.indexOf(to.path) !== -1) {
-
- next()
- } else {
- if (process.env.VUE_APP_IFRAME_CHECK === 'TRUE') {
- next({
- path: '/top',
- query: {
- redirect: to.fullPath
- }
- })
- } else {
- next({
- path: '/user/login',
- query: {
- redirect: to.fullPath
- }
- })
- }
- NProgress.done()
- }
- }
- })
- router.afterEach(() => {
- NProgress.done()
- })
- }
- export default initRouter
|