2020-01-13 19:04:03 +08:00
|
|
|
|
//import "./assets/css/main.css";
|
2020-01-17 16:50:17 +08:00
|
|
|
|
import './assets/stylus/index.scss'
|
2019-12-27 17:53:17 +08:00
|
|
|
|
import "./assets/css/nzIcon.css";
|
2020-02-12 12:06:37 +08:00
|
|
|
|
import "./assets/css/main.css";
|
2019-11-29 15:00:26 +08:00
|
|
|
|
import 'element-ui/lib/theme-chalk/index.css';
|
|
|
|
|
|
import ElementUI from 'element-ui';
|
2019-12-26 17:28:04 +08:00
|
|
|
|
import 'xterm/dist/xterm.css'
|
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'
|
2020-01-08 22:19:46 +08:00
|
|
|
|
import VueResource from 'vue-resource'
|
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-17 17:17:30 +08:00
|
|
|
|
import searchInput from "./components/common/searchInput"; //搜索框组件
|
2020-01-08 22:19:46 +08:00
|
|
|
|
import elementSet from "./components/common/elementSet"; //自定义表头组件
|
|
|
|
|
|
|
2019-12-18 17:00:44 +08:00
|
|
|
|
import projectBox from './components/common/rightBox/projectBox'; //project弹框组件
|
|
|
|
|
|
import moduleBox from './components/common/rightBox/moduleBox'; //module弹框组件
|
2019-12-20 17:18:30 +08:00
|
|
|
|
import editEndpointBox from './components/common/rightBox/editEndpointBox'; //endpoint弹框组件
|
|
|
|
|
|
import addEndpointBox from './components/common/rightBox/addEndpointBox'; //endpoint弹框组件
|
2019-12-23 15:43:05 +08:00
|
|
|
|
import assetAddUnit from "./components/page/asset/assetAddUnit"; //资产添加组件
|
|
|
|
|
|
import assetEditUnit from "./components/page/asset/assetEditUnit"; //资产添加组件
|
2020-02-19 16:33:01 +08:00
|
|
|
|
import assetBox from "./components/common/rightBox/assetBox"; //资产添加组件
|
2019-12-24 17:31:51 +08:00
|
|
|
|
import alertConfigBox from "./components/common/rightBox/alertConfigBox"; //告警规则弹框组件
|
2020-01-10 18:16:25 +08:00
|
|
|
|
import dcConfigBox from "./components/common/popBox/dcConfig"; //idc配置弹框组件
|
2020-01-03 17:17:09 +08:00
|
|
|
|
import panelBox from "./components/common/rightBox/panelBox"; //面板弹框组件
|
2020-01-09 19:30:43 +08:00
|
|
|
|
import moduleListPop from "./components/page/asset/moduleListPop"; //面板弹框组件
|
2020-01-10 18:16:25 +08:00
|
|
|
|
import cabinetConfigBox from "./components/common/popBox/cabinetConfig"; //面板弹框组件
|
2020-02-21 17:57:19 +08:00
|
|
|
|
import dcBox from "./components/common/rightBox/dcBox"; //dc弹框
|
|
|
|
|
|
|
2019-12-16 17:14:58 +08:00
|
|
|
|
|
2019-12-02 16:16:26 +08:00
|
|
|
|
Vue.component("Pagination", Pagination);
|
2019-12-16 17:14:58 +08:00
|
|
|
|
Vue.component("searchInput", searchInput);
|
2020-01-08 22:19:46 +08:00
|
|
|
|
Vue.component("element-set", elementSet);
|
2019-12-18 17:00:44 +08:00
|
|
|
|
Vue.component("project-box", projectBox);
|
|
|
|
|
|
Vue.component("module-box", moduleBox);
|
2019-12-19 17:22:18 +08:00
|
|
|
|
Vue.component("edit-endpoint-box", editEndpointBox);
|
2019-12-20 17:18:30 +08:00
|
|
|
|
Vue.component("add-endpoint-box", addEndpointBox);
|
2020-02-19 16:33:01 +08:00
|
|
|
|
Vue.component("asset-box", assetBox);
|
2019-12-23 15:43:05 +08:00
|
|
|
|
Vue.component("assetAddUnit", assetAddUnit);
|
|
|
|
|
|
Vue.component("assetEditUnit", assetEditUnit);
|
2019-12-24 17:31:51 +08:00
|
|
|
|
Vue.component("alert-config-box", alertConfigBox);
|
2020-01-03 16:04:23 +08:00
|
|
|
|
Vue.component("idc-config-box", dcConfigBox);
|
2020-01-03 17:17:09 +08:00
|
|
|
|
Vue.component("panel-box", panelBox);
|
2020-01-09 19:30:43 +08:00
|
|
|
|
Vue.component("module-list-pop", moduleListPop);
|
2020-01-10 18:16:25 +08:00
|
|
|
|
Vue.component("cabinet-config-box", cabinetConfigBox);
|
2020-02-21 17:57:19 +08:00
|
|
|
|
Vue.component("dc-box", dcBox);
|
2019-12-02 16:16:26 +08:00
|
|
|
|
|
2019-12-17 17:17:30 +08:00
|
|
|
|
Vue.prototype.$axios = axios;
|
2019-12-02 16:16:26 +08:00
|
|
|
|
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
|
|
|
|
|
2019-12-17 17:17:30 +08:00
|
|
|
|
Vue.config.productionTip = false;
|
|
|
|
|
|
Vue.use(ElementUI);
|
|
|
|
|
|
Vue.use(Vuex);
|
2020-01-08 22:19:46 +08:00
|
|
|
|
Vue.use(VueResource);
|
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 */
|
2019-12-26 17:28:04 +08:00
|
|
|
|
window.vm = new Vue({
|
2019-11-28 18:23:49 +08:00
|
|
|
|
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
|
|
|
|
|
2019-12-26 17:28:04 +08:00
|
|
|
|
export default vm
|
2019-12-12 17:07:33 +08:00
|
|
|
|
router.beforeEach((to, from, next) => {
|
|
|
|
|
|
if (to.path === '/login') {
|
|
|
|
|
|
next()
|
|
|
|
|
|
} else {
|
2019-12-26 18:06:51 +08:00
|
|
|
|
let token = sessionStorage.getItem('nz-token');
|
2019-12-12 17:07:33 +08:00
|
|
|
|
if (token) {
|
|
|
|
|
|
next()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
next({ path: '/dashboard' })
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|