2019-11-29 15:00:26 +08:00
|
|
|
|
import "./assets/css/main.css";
|
|
|
|
|
|
import 'element-ui/lib/theme-chalk/index.css';
|
|
|
|
|
|
import ElementUI from 'element-ui';
|
|
|
|
|
|
|
2019-12-02 16:16:26 +08:00
|
|
|
|
import i18n from './components/common/i18n'
|
2019-11-29 15:00:26 +08:00
|
|
|
|
|
2019-11-28 18:23:49 +08:00
|
|
|
|
import Vue from 'vue'
|
2019-12-05 16:48:23 +08:00
|
|
|
|
import Vuex from 'vuex'
|
|
|
|
|
|
import store from './store/index';
|
2019-11-28 18:23:49 +08:00
|
|
|
|
import App from './App'
|
|
|
|
|
|
import router from './router'
|
2019-12-05 16:48:23 +08:00
|
|
|
|
|
|
|
|
|
|
|
2019-12-02 16:16:26 +08:00
|
|
|
|
import axios from 'axios';
|
2019-12-09 19:23:20 +08:00
|
|
|
|
import {post, get, put, del} from './http.js'
|
2019-12-02 16:16:26 +08:00
|
|
|
|
|
|
|
|
|
|
import Pagination from "./components/common/pagination"; //引入全局分页组件
|
2019-12-16 17:14:58 +08:00
|
|
|
|
import searchInput from "./components/common/searchInput";
|
|
|
|
|
|
|
2019-12-02 16:16:26 +08:00
|
|
|
|
Vue.component("Pagination", Pagination);
|
2019-12-16 17:14:58 +08:00
|
|
|
|
Vue.component("searchInput", searchInput);
|
2019-12-02 16:16:26 +08:00
|
|
|
|
|
|
|
|
|
|
Vue.prototype.$axios = axios
|
|
|
|
|
|
Vue.prototype.$post = post;
|
|
|
|
|
|
Vue.prototype.$get = get;
|
2019-12-09 19:23:20 +08:00
|
|
|
|
Vue.prototype.$put = put;
|
|
|
|
|
|
Vue.prototype.$delete = del;
|
2019-11-28 18:23:49 +08:00
|
|
|
|
|
|
|
|
|
|
Vue.config.productionTip = false
|
2019-11-29 15:00:26 +08:00
|
|
|
|
Vue.use(ElementUI)
|
2019-12-05 16:48:23 +08:00
|
|
|
|
Vue.use(Vuex)
|
2019-11-28 18:23:49 +08:00
|
|
|
|
|
2019-12-04 13:45:37 +08:00
|
|
|
|
|
|
|
|
|
|
const clickoutside = {
|
|
|
|
|
|
// 初始化指令
|
|
|
|
|
|
bind(el, binding, vnode) {
|
|
|
|
|
|
function documentHandler(e) {
|
|
|
|
|
|
// 这里判断点击的元素是否是本身,是本身,则返回
|
|
|
|
|
|
if (el.contains(e.target)) {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 判断指令中是否绑定了函数
|
|
|
|
|
|
if (binding.expression) {
|
|
|
|
|
|
// 如果绑定了函数 则调用那个函数,此处binding.value就是handleClose方法
|
|
|
|
|
|
if (binding.arg) {
|
|
|
|
|
|
binding.value(e, binding.arg);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
binding.value(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-12-05 16:48:23 +08:00
|
|
|
|
|
2019-12-04 13:45:37 +08:00
|
|
|
|
// 给当前元素绑定个私有变量,方便在unbind中可以解除事件监听
|
|
|
|
|
|
el.__vueClickOutside__ = documentHandler;
|
|
|
|
|
|
document.addEventListener('click', documentHandler);
|
|
|
|
|
|
},
|
|
|
|
|
|
unbind(el, binding) {
|
|
|
|
|
|
// 解除事件监听
|
|
|
|
|
|
document.removeEventListener('click', el.__vueClickOutside__);
|
|
|
|
|
|
delete el.__vueClickOutside__;
|
|
|
|
|
|
},
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
Vue.directive('clickoutside',
|
|
|
|
|
|
clickoutside
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2019-11-28 18:23:49 +08:00
|
|
|
|
/* eslint-disable no-new */
|
|
|
|
|
|
new Vue({
|
|
|
|
|
|
el: '#app',
|
|
|
|
|
|
router,
|
2019-12-02 16:16:26 +08:00
|
|
|
|
i18n,
|
2019-12-05 16:48:23 +08:00
|
|
|
|
store,
|
|
|
|
|
|
components: {App},
|
2019-11-28 18:23:49 +08:00
|
|
|
|
template: '<App/>'
|
|
|
|
|
|
})
|
2019-12-12 17:07:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
|
|
|
if (to.path === '/login') {
|
|
|
|
|
|
next()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
let token = sessionStorage.getItem('token');
|
|
|
|
|
|
if (token) {
|
|
|
|
|
|
next()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
next({ path: '/dashboard' })
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|