main.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 = Vue.prototype.DOMIN // 翟毅飞本地图片服务器路径常量
  49. // Vue.prototype.$imghost = 'http://www.hnyfwlw.com:8006/projectimg' // 线上图片服务器路径常量
  50. Vue.prototype.$insectHost = 'https://images.weserv.nl/?url=' // 线上图片服务器路径常量
  51. Vue.prototype.$wsUrl = Vue.prototype.wsUrl // 实时通信服务器url
  52. // Vue.prototype.$deriveData = Vue.prototype.DOMIN // 导出
  53. Vue.prototype.$deriveData = 'http://114.115.147.140:12345' // 导出
  54. Vue.prototype.$faultvideo = Vue.prototype.DOMIN //售后视频地址前缀
  55. import VueHighcharts from 'vue-highcharts';
  56. Vue.use(VueHighcharts);
  57. Vue.prototype.$axios = axios //全局注册,使用方法为:this.$axios
  58. Vue.prototype.$EventBus = new Vue()
  59. Vue.prototype.qs = Qs //全局注册,使用方法为:this.qs
  60. import './util/http.js'
  61. // import './assets/css/global.css'
  62. import './assets/icon/iconfont.css'
  63. //格式化时间戳
  64. import './util/formatTime'
  65. Vue.directive('btnRight', {
  66. inserted: function (el, binding, vnode) {
  67. const optName = binding.arg;
  68. const routeName = binding.value.slice(7); //路由地址
  69. const authName = `${routeName}_${optName}` //这里根据路由名和操作类型拼出按钮名 overview-edit
  70. const btnRightList = store.getters.btnRight;
  71. if (btnRightList[authName] == 0) {
  72. el.parentNode.removeChild(el)
  73. } else if (btnRightList[authName] == 1) { }
  74. }
  75. })
  76. import VueLazyLoad from 'vue-lazyload'
  77. Vue.use(VueLazyLoad, {
  78. preLoad: 1,
  79. error: require('./assets/images/newImg/noimage.png'),
  80. loading: require('./assets/images/newImg/shot-1.gif'),
  81. attempt: 2,
  82. })
  83. router.beforeEach(async (to, from, next) => {
  84. console.log(to)
  85. if (to.path == '/Login'||to.path == '/') {
  86. next()
  87. }else{
  88. if(localStorage.getItem("session")){
  89. next()
  90. }else{
  91. next({
  92. path: '/Login'
  93. });
  94. }
  95. }
  96. })
  97. //节流
  98. function throttle() {
  99. let prev = 0
  100. Vue.prototype.$throttle = function (func, wait) {
  101. let now = Date.now()
  102. if (now - prev > wait) {
  103. func.apply(this)
  104. prev = now
  105. }
  106. }
  107. }
  108. throttle()
  109. /* eslint-disable no-new */
  110. new Vue({
  111. el: '#app',
  112. router,
  113. components: { App },
  114. template: '<App/>'
  115. })