|
@ -10,6 +10,7 @@ import Login from '@/views/login/Login'
|
|
import Register from '@/views/login/Register'
|
|
import Register from '@/views/login/Register'
|
|
import FotgetPassword from '@/views/login/FotgetPassword'
|
|
import FotgetPassword from '@/views/login/FotgetPassword'
|
|
import Index from '@/views/index/Index'
|
|
import Index from '@/views/index/Index'
|
|
|
|
import device from './device'
|
|
Vue.use(VueRouter)
|
|
Vue.use(VueRouter)
|
|
|
|
|
|
const routes = [
|
|
const routes = [
|
|
@ -69,7 +70,7 @@ const whiteList = [
|
|
const router = new VueRouter({
|
|
const router = new VueRouter({
|
|
mode: 'history',
|
|
mode: 'history',
|
|
base: process.env.BASE_URL,
|
|
base: process.env.BASE_URL,
|
|
routes: routes.concat( [] )
|
|
|
|
|
|
routes: routes.concat( device )
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
@ -84,6 +85,8 @@ function redirectToLogin(to, from, next) {
|
|
|
|
|
|
if(process.env.NODE_ENV==='production') {
|
|
if(process.env.NODE_ENV==='production') {
|
|
router.beforeEach(async (to, from, next) => {
|
|
router.beforeEach(async (to, from, next) => {
|
|
|
|
next()
|
|
|
|
return
|
|
if((store.getters.user && store.getters.user.accessToken)) {
|
|
if((store.getters.user && store.getters.user.accessToken)) {
|
|
next()
|
|
next()
|
|
} else {
|
|
} else {
|
|
@ -96,6 +99,8 @@ if(process.env.NODE_ENV==='production') {
|
|
})
|
|
})
|
|
} else {
|
|
} else {
|
|
router.beforeEach(async (to, from, next) => {
|
|
router.beforeEach(async (to, from, next) => {
|
|
|
|
next()
|
|
|
|
return
|
|
if ((!store.getters.user || !store.getters.user.accessToken) && whiteList.indexOf(to.path) == -1) {
|
|
if ((!store.getters.user || !store.getters.user.accessToken) && whiteList.indexOf(to.path) == -1) {
|
|
next('/login')
|
|
next('/login')
|
|
return
|
|
return
|