main.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. // ie polyfill
  2. import '@babel/polyfill'
  3. import Vue from 'vue'
  4. import App from './App.vue'
  5. import router from './router'
  6. import store from './store/'
  7. import { VueAxios } from './utils/request'
  8. import Viewer from 'v-viewer'
  9. import 'viewerjs/dist/viewer.css'
  10. import VueUeditorWrap from 'vue-ueditor-wrap'
  11. // mock
  12. // import './mock'
  13. import bootstrap from './core/bootstrap'
  14. import './core/use'
  15. import './permission' // permission control
  16. import './utils/filter' // global filter
  17. import BaseTool from './utils/install'
  18. // import echarts from 'echarts'
  19. import VueI18n from 'vue-i18n'
  20. import Print from 'vue-print-nb' // 注册
  21. import ChartPanel from '@/components/ChartView/index.vue'
  22. Vue.use(Print)
  23. Vue.component(ChartPanel.name, ChartPanel)
  24. // Vue.prototype.$echarts = echarts
  25. Vue.config.productionTip = false
  26. // mount axios Vue.$http and this.$http
  27. Vue.use(VueAxios)
  28. Vue.use(BaseTool)
  29. Vue.use(VueI18n) // 通过插件的形式挂载
  30. Vue.use(Viewer)
  31. Vue.component('vue-ueditor-wrap', VueUeditorWrap)
  32. export const eventBus = new Vue()
  33. Vue.prototype.$eventBus = eventBus
  34. Vue.directive('drag-modal', (el, bindings, vnode) => {
  35. Vue.nextTick(() => {
  36. const { visible, destroyOnClose } = vnode.componentInstance
  37. // 防止未定义 destroyOnClose 关闭弹窗时dom未被销毁,指令被重复调用
  38. if (!visible) return
  39. const modal = el.getElementsByClassName('ant-modal')[0]
  40. const header = el.getElementsByClassName('ant-modal-header')[0]
  41. let left = 0
  42. let top = 0
  43. // 未定义 destroyOnClose 时,dom未被销毁,关闭弹窗再次打开,弹窗会停留在上一次拖动的位置
  44. if (!destroyOnClose) {
  45. left = modal.left || 0
  46. top = modal.top || 0
  47. }
  48. // top 初始值为 offsetTop
  49. top = top || modal.offsetTop
  50. header.onmousedown = e => {
  51. const startX = e.clientX
  52. const startY = e.clientY
  53. header.left = header.offsetLeft
  54. header.top = header.offsetTop
  55. el.onmousemove = event => {
  56. const endX = event.clientX
  57. const endY = event.clientY
  58. modal.left = header.left + (endX - startX) + left
  59. modal.top = header.top + (endY - startY) + top
  60. modal.style.left = modal.left + 'px'
  61. modal.style.top = modal.top + 'px'
  62. }
  63. el.onmouseup = event => {
  64. left = modal.left
  65. top = modal.top
  66. el.onmousemove = null
  67. el.onmouseup = null
  68. header.releaseCapture && header.releaseCapture()
  69. }
  70. header.setCapture && header.setCapture()
  71. }
  72. })
  73. })
  74. const i18n = new VueI18n({
  75. // locale: localStorage.getItem('locale') || 'zh-CN',
  76. locale: 'zh-CN',
  77. messages: {
  78. 'zh-CN': require('./i18n/zh')
  79. // 'en-US': require('./i18n/en')
  80. }
  81. })
  82. Viewer.setDefaults({
  83. Options: {
  84. inline: true,
  85. button: false,
  86. navbar: true,
  87. title: true,
  88. toolbar: true,
  89. tooltip: true,
  90. movable: true,
  91. zoomable: true,
  92. rotatable: true,
  93. scalable: true,
  94. transition: true,
  95. fullscreen: true,
  96. keyboard: true,
  97. url: 'data-source'
  98. }
  99. })
  100. new Vue({
  101. i18n,
  102. router,
  103. store,
  104. created: bootstrap,
  105. render: h => h(App)
  106. }).$mount('#app')