main.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import Vue from 'vue'
  2. import App from './App'
  3. import ElementUI from 'element-ui';
  4. import router from './router'
  5. import store from '@/store/store.js'
  6. import less from 'less'
  7. Vue.use(less)
  8. import './assets/js/directives'; // 实现elementui对话框可拖拽功能
  9. import drag from '@/assets/js/drag'; // 实现div弹框可拖拽功能
  10. Vue.prototype.$deriveData = Vue.prototype.DOMIN // 导出
  11. import Viewer from 'v-viewer'
  12. import 'viewerjs/dist/viewer.css'
  13. Vue.use(Viewer, {
  14. defaultOptions: {
  15. "zIndex": 9999,
  16. }
  17. })
  18. // import Viewer from 'v-viewer'
  19. // import 'viewerjs/dist/viewer.css'
  20. // Vue.use(Viewer)
  21. // Viewer.setDefaults({
  22. // Options: {
  23. // inline: true,
  24. // button: false,
  25. // navbar: true,
  26. // title: true,
  27. // toolbar: true,
  28. // tooltip: true,
  29. // movable: true,
  30. // zoomable: true,
  31. // rotatable: true,
  32. // scalable: true,
  33. // transition: true,
  34. // fullscreen: true,
  35. // keyboard: true,
  36. // url: 'data-source'
  37. // }
  38. // })
  39. import echarts from 'echarts'
  40. Vue.prototype.$echarts = echarts
  41. // import $ from 'jquery'
  42. Vue.prototype.$store = store
  43. import 'element-ui/lib/theme-chalk/index.css'
  44. Vue.use(ElementUI);
  45. Vue.config.productionTip = false
  46. const axios = require('axios')
  47. const Qs = require('qs')
  48. Vue.prototype.$imghost = 'http://www.hnyfwlw.com:8006/projectimg' // 线上图片服务器路径常量
  49. Vue.prototype.$insectHost = 'https://images.weserv.nl/?url=' // 线上图片服务器路径常量
  50. Vue.prototype.$deriveData = Vue.prototype.DOMIN // 导出
  51. // Vue.prototype.$deriveData = 'http://192.168.1.112:8002' // 导出
  52. Vue.prototype.$faultvideo = 'http://192.168.1.3:8000' //售后视频地址前缀
  53. import VueHighcharts from 'vue-highcharts';
  54. Vue.use(VueHighcharts);
  55. Vue.prototype.$axios = axios //全局注册,使用方法为:this.$axios
  56. Vue.prototype.$EventBus = new Vue()
  57. Vue.prototype.qs = Qs //全局注册,使用方法为:this.qs
  58. import './util/http.js'
  59. // import './assets/css/global.css'
  60. import './assets/icon/iconfont.css'
  61. //格式化时间戳
  62. import './util/formatTime'
  63. Vue.directive('btnRight', {
  64. inserted: function (el, binding, vnode) {
  65. const optName = binding.arg;
  66. const routeName = binding.value.slice(7); //路由地址
  67. const authName = `${routeName}_${optName}` //这里根据路由名和操作类型拼出按钮名 overview-edit
  68. const btnRightList = store.getters.btnRight;
  69. if (btnRightList[authName] == 0) {
  70. el.parentNode.removeChild(el)
  71. } else if (btnRightList[authName] == 1) { }
  72. }
  73. })
  74. import VueLazyLoad from 'vue-lazyload'
  75. Vue.use(VueLazyLoad, {
  76. preLoad: 1,
  77. error: require('./assets/images/newImg/noimage.png'),
  78. loading: require('./assets/images/newImg/shot-1.gif'),
  79. attempt: 2,
  80. })
  81. router.beforeEach(async (to, from, next) => {
  82. console.log(to)
  83. if (to.path == '/Login'||to.path == '/') {
  84. next()
  85. }else{
  86. if(localStorage.getItem("session")){
  87. next()
  88. }else{
  89. next({
  90. path: '/Login'
  91. });
  92. }
  93. }
  94. })
  95. /* eslint-disable no-new */
  96. new Vue({
  97. el: '#app',
  98. router,
  99. components: { App },
  100. template: '<App/>'
  101. })