import Vue from 'vue'
|
import App from './App.vue'
|
// import './registerServiceWorker'
|
import router from './router/index.js'
|
import store from './store/index.js'
|
// 禁止缩放
|
import './script/unCtrl.js'
|
// import axios from 'axios'
|
import './assets/iconfont/iconfont.css'
|
import 'element-ui/lib/theme-chalk/index.css'
|
import './assets/css/m-element-ui.css'
|
import './assets/css/common.css'
|
|
import G from './global'
|
import common from './script/common.js'
|
import config from './script/config.js'
|
import user from './script/user.js'
|
import filters from './script/filter.js'
|
import event from './script/event.js'
|
|
|
import './api'
|
|
import ElementUI from 'element-ui'
|
|
import layer from 'vue-layer'
|
import 'vue-layer/lib/vue-layer.css';
|
Vue.prototype.$layer = layer(Vue);
|
|
import './script/directive.js';
|
|
Vue.use(ElementUI);
|
import './assets/css/theme.css';
|
|
// Vue.prototype.$message = Message;
|
Vue.prototype.$common = common;
|
Vue.prototype.$config = config;
|
Vue.prototype.$user = user;
|
Vue.prototype.$G = G;
|
Vue.prototype.$event = event;
|
// Vue.prototype.$api = api;
|
|
// 注册自定义过滤器
|
for(const key in filters){
|
// console.log(key, filters[key]);
|
Vue.filter(key, filters[key]);
|
}
|
//格式化时间
|
Date.prototype.format = function (format) {
|
var o = {
|
"M+" : this.getMonth()+1, //month
|
"d+" : this.getDate(), //day
|
"h+" : this.getHours(), //hour
|
"m+" : this.getMinutes(), //minute
|
"s+" : this.getSeconds(), //second
|
"q+" : Math.floor((this.getMonth()+3)/3), //quarter
|
"S" : this.getMilliseconds() //millisecond
|
};
|
if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
|
(this.getFullYear()+"").substr(4- RegExp.$1.length));
|
for(var k in o)if(new RegExp("("+ k +")").test(format))
|
format = format.replace(RegExp.$1,
|
RegExp.$1.length==1? o[k] :
|
("00"+ o[k]).substr((""+ o[k]).length));
|
return format;
|
};
|
// Vue.config.productionTip = false;
|
|
|
|
const setHtmlFontSize = () => {
|
const htmlDom = document.getElementsByTagName('html')[0];
|
let htmlWidth = document.documentElement.clientWidth || document.body.clientWidth;
|
if (htmlWidth >= 750) {
|
htmlWidth = 750;
|
}
|
if (htmlWidth <= 320) {
|
htmlWidth = 320;
|
}
|
htmlDom.style.fontSize = `${htmlWidth / 7.5}px`;
|
};
|
|
// 进入路由前
|
router.beforeEach((to, from, next) => {
|
// console.log(to, '----to------from----', from);
|
// 用户是否已登录
|
let isLogin = common.getSession('login') && common.getSession('login') != 'false';
|
// console.log(isLogin, 'isLogin..', typeof isLogin);
|
if (isLogin) {
|
if ('/' == to.path) {
|
next({path:'/general/index'});
|
return false;
|
}
|
} else {
|
if ('/login' != to.path) {
|
next({path:'/login'});
|
return false;
|
}
|
}
|
// debugger;
|
|
// 修改主导航的激活状态
|
store.dispatch('changeNavName', to.name);
|
// 修改面包屑导航内容
|
store.dispatch('changeCrumb', to.meta.crumb);
|
next();
|
});
|
|
// window.onresize = setHtmlFontSize;
|
window.addEventListener('resize', setHtmlFontSize);
|
|
setHtmlFontSize();
|
|
new Vue({
|
router,
|
store,
|
render: h => h(App),
|
}).$mount('#app')
|