kun 9/23 20:12

This commit is contained in:
沈学坤
2019-09-23 20:12:30 +08:00
parent 5372695dcc
commit 1474d83d39
26 changed files with 1535 additions and 302 deletions

View File

@@ -2,20 +2,42 @@ import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import http from '../static/js/http'
import ElementUI from 'element-ui'
import md5 from 'js-md5'
import '../static/css/reset.css'
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.$http = http
Vue.prototype.$jump = function (url) {
this.$router.push({
name: url
})
}
Vue.prototype.$jParams = function (url, parameters) {
this.$router.push({
name: url,