import Vue from ‘vue‘
import ‘normalize.css/normalize.css‘// A modern alternative to CSS resets
import ElementUI from ‘element-ui‘
import ‘element-ui/lib/theme-chalk/index.css‘
import locale from ‘element-ui/lib/locale/lang/zh-CN‘
import App from ‘./App‘
import router from ‘./router‘
import store from ‘./store‘
import ‘@/icons‘ // icon
import ‘@/permission‘ // 权限
import ‘@/components/ImgIcon‘ // 底footer 图标
import {default as api} from ‘./utils/api‘
import {hasPermission} from "./utils/hasPermission";
import plugin from ‘./plugin‘
import {axiosAsync, getAllDictionary, code2name,showMarksBySwitchBtn,resetALlSwitchBtn,getHuangpuPoints} from ‘./utils/commonApi‘
import VuePhotoZoomPro from ‘vue-photo-zoom-pro‘
Vue.use(VuePhotoZoomPro)
import echarts from ‘echarts‘ //引入echarts
Vue.prototype.$echarts = echarts //引入组件
import $ from ‘jquery‘
import commonMap from "./assets/js/map.js";//地图引入
import VueAwesomeSwiper from "vue-awesome-swiper";
console.dir(Vue,‘vuemain‘)
Vue.use(ElementUI, {locale})
Vue.prototype.api = api
Vue.prototype.$axiosAsync = axiosAsync;
Vue.prototype.getAllDictionary = getAllDictionary;
Vue.prototype.showMarksBySwitchBtn = showMarksBySwitchBtn;
Vue.prototype.resetALlSwitchBtn = resetALlSwitchBtn;
Vue.prototype.getHuangpuPoints = getHuangpuPoints;
Vue.prototype.$code2name = code2name;
$.extend(Vue.prototype,{ commonMap: commonMap});
//全局的常量
Vue.prototype.hasPerm = hasPermission
//生产环境时自动设置为 false 以阻止 vue 在启动时生成生产提示。
Vue.config.productionTip = (process.env.NODE_ENV != ‘production‘)
Vue.use(plugin);
Vue.use(VueAwesomeSwiper /* { default global options } */);
//修改dev
new Vue({
el: ‘#app‘,
router,
store,
template: ‘<App/>‘,
components: {App}
})
import router from ‘./router‘
import store from ‘./store‘
import NProgress from ‘nprogress‘ // Progress 进度条
import ‘nprogress/nprogress.css‘ // Progress 进度条样式
import {getToken,removeToken} from ‘@/utils/auth‘ // 验权
const whiteList = [‘/login‘, ‘/404‘, ‘/home‘] //白名单,不需要登录的路由
router.beforeEach((to, from, next) => {
next();
// NProgress.start();
// next({path: ‘/‘});
// NProgress.done();
// removeToken();
// else if (!store.getters.role) {
// store.dispatch(‘GetInfo‘).then(() => {
// next({...to})
// })
// }
if (getToken()) {
//如果已经登录
if (to.path === ‘/login‘) {
next({path: ‘/‘})
NProgress.done() // 结束Progress
} else {
next()
}
} else if (whiteList.indexOf(to.path) !== -1) {
//如果前往的路径是白名单内的,就可以直接前往
next()
} else {
//如果路径不是白名单内的,而且又没有登录,就跳转登录页面
next(‘/login‘)
NProgress.done() // 结束Progress
}
})
router.afterEach(() => {
NProgress.done() // 结束Progress
})