xiaota-main
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store'
import Axios from 'axios'
import $ from 'jquery'
import HttpRequest from '@/common/js/axios'
Vue.config.productionTip = false
Vue.prototype.$http = HttpRequest;
// 引入element
import ElementUI from 'element-ui'
Vue.use(ElementUI)
// 引入全局函数
import global from './global'
Vue.use(global);
//
import VueClipboard from 'vue-clipboard2'
Vue.use(VueClipboard)
// 懒加载
import VueLazyload from 'vue-lazyload'
Vue.use(VueLazyload)
function getCookieItem(key){
var arr = document.cookie.split("; ");
for(var i = 0; i<arr.length; i++) {
var res = arr[i].split("=");
if (res[0] == key) {
if(res.length==3){
return res[1]+'=';
}else{
return res[1];
}
}
}
}
// 登录
router.beforeEach((to, from, next) => {
const [directorAutoLogin,directorToken] = [getCookieItem('directorAutoLogin'),getCookieItem('directorToken')];
if (!directorToken && to.path !== '/login') {
next('/login');
} else {
next();
}
if(directorAutoLogin&&to.path === '/login'){
next('/management');
}
})
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
store,
$,
components: { App },
template: '<App/>'
})