// 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 Vuex from 'vuex' //import promise from 'es6-promise'; import App from './App'; import router from './router'; import axios from './components/common/axios'// 'axios'; import moment from 'moment'; import ElementUI from 'element-ui'; import 'element-ui/lib/theme-chalk/index.css'; // 默认主题 // import '../static/css/theme-green/index.css'; // 浅绿色主题 //import './assets/css/icon.css'; import './components/common/directives'; import 'babel-polyfill'; import './core/directives/action' //promise.polyfill(); // import VCharts from 'v-charts-v2' import VeLine from 'v-charts/lib/line' import VeHistogram from 'v-charts/lib/histogram' import moneyConverter from './components/common/tool.js' import isMobile from './components/common/isMobile' Vue.prototype.$isMobile = isMobile // 用$与组件内自定义的函数区分,其他符号也可以 Vue.config.productionTip = false //axios.defaults.baseURL = "http://localhost:8080"; //Vue.use(Vuex) axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; Vue.prototype.$axios = axios; Vue.prototype.$moment = moment; Vue.prototype.moneyConverter = moneyConverter; Vue._watchers = Vue.prototype._watchers = []; moment.locale('zh-cn'); Vue.use(ElementUI, { size: 'small' }); // Vue.use(VCharts) Vue.component(VeLine.name, VeLine) Vue.component(VeHistogram.name, VeHistogram) String.prototype.startsWith = function(str){ if (str == null || str == "" || this.length == 0 || str.length > this.length) return false; if (this.substr(0, str.length) == str) return true; else return false; } router.beforeEach((to, from, next) => { let token = localStorage.getItem('token'); console.log('==============路由拦截==============='); if (to.path.indexOf('/login') != -1) { next(); } else if (to.path.startsWith('/admin')) { let user = localStorage.getItem('am_username'); if (token == null || user == null) { next('/admin/login'); } next(); } else if (to.path.startsWith('/third')) { let user = localStorage.getItem('th_username'); if (token == null || user == null) { next('/third/login'); } next(); } else { if (token === null || token === '') { next('/admin/login'); } else { next(); } } }); /* eslint-disable no-new */ new Vue({ router, render: h => h(App) }).$mount('#app')