kun 19/10/1/20:45
This commit is contained in:
22
src/main.js
22
src/main.js
@@ -2,7 +2,7 @@ import Vue from 'vue'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
import store from './store'
|
||||
import http from '../static/js/http'
|
||||
import http from './http'
|
||||
import tool from '../static/js/tool'
|
||||
import ElementUI from 'element-ui'
|
||||
import md5 from 'js-md5'
|
||||
@@ -12,26 +12,6 @@ import '../static/css/swiper.css'
|
||||
import '../static/fonts/iconfont.css'
|
||||
import 'element-ui/lib/theme-chalk/index.css'
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.meta.requireAuth) {
|
||||
// 判断该路由是否需要登录权限
|
||||
if (localStorage.token) {
|
||||
// 获取当前的token是否存在
|
||||
console.log('token存在')
|
||||
next()
|
||||
} else {
|
||||
console.log('token不存在')
|
||||
next({
|
||||
path: '/login', // 将跳转的路由path作为参数,登录成功后跳转到该路由
|
||||
query: { redirect: to.fullPath }
|
||||
})
|
||||
}
|
||||
} else {
|
||||
// 如果不需要权限校验,直接进入路由界面
|
||||
next()
|
||||
}
|
||||
})
|
||||
|
||||
Vue.prototype.$md5 = md5
|
||||
Vue.prototype.$tool = tool
|
||||
Vue.prototype.$http = http
|
||||
|
||||
Reference in New Issue
Block a user