main.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. import Vue from 'vue'
  2. import VueRouter from 'vue-router'
  3. import 'normalize.css/normalize.css' // A modern alternative to CSS resets
  4. import ElementUI from 'element-ui'
  5. import 'element-ui/lib/theme-chalk/index.css'
  6. import UmyUi from 'umy-ui'
  7. import 'umy-ui/lib/theme-chalk/index.css';// 引入样式
  8. // const ElementUI = require('element-ui')
  9. // require('element-ui/lib/theme-chalk/index.css')
  10. import locale from 'element-ui/lib/locale/lang/zh-CN' // lang i18n
  11. import iconfont from './assets/iconfont/iconfont.css'
  12. import '@/styles/index.scss' // global css
  13. import * as Sentry from '@sentry/browser'
  14. import {
  15. Vue as VueIntegration
  16. } from '@sentry/integrations'
  17. import App from './App'
  18. import store from './store'
  19. import router from './router'
  20. import i18n from './i18n'
  21. import '@/icons' // icon
  22. import '@/permission' // permission control
  23. import './icons'
  24. import * as filters from './filters' // global filters
  25. Vue.config.productionTip = false
  26. /**
  27. * If you don't want to use mock-server
  28. * you want to use MockJs for mock api
  29. * you can execute: mockXHR()
  30. *
  31. * Currently MockJs will be used in the production environment,
  32. * please remove it before going online! ! !
  33. */
  34. // import { mockXHR } from '../mock'
  35. if (process.env.NODE_ENV === 'production') {
  36. // mockXHR()
  37. }
  38. var pageCount = 50
  39. // console.log(process.env)
  40. if (process.env.NODE_ENV !== 'development') {
  41. Sentry.init({
  42. release: 'vislib@' + process.env.npm_package_version,
  43. dsn: 'https://9d8ee0ea1a2749949dd1e641b0f7c071@o286322.ingest.sentry.io/5217806',
  44. integrations: [new VueIntegration({
  45. Vue,
  46. attachProps: true
  47. })]
  48. })
  49. }
  50. // store.commit('app/SET_LANG', 'CN')
  51. Vue.use(VueRouter)
  52. Vue.use(pageCount)
  53. Vue.use(ElementUI, {
  54. i18n: (key, value) => i18n.t(key, value)
  55. })
  56. Vue.use(UmyUi);
  57. // register global utility filters
  58. Object.keys(filters).forEach(key => {
  59. Vue.filter(key, filters[key])
  60. })
  61. // import echarts from 'echarts'
  62. import * as echarts from 'echarts'
  63. Vue.use(echarts)
  64. // Vue.prototype.$echarts = echarts
  65. new Vue({
  66. el: '#app',
  67. router,
  68. store,
  69. i18n,
  70. render: h => h(App)
  71. })
  72. Vue.directive('loadmore', {
  73. bind(el, binding) {
  74. const selectWrap = el.querySelector('.el-table__body-wrapper')
  75. selectWrap.addEventListener('scroll', function() {
  76. let sign = 0
  77. const scrollDistance = this.scrollHeight - this.scrollTop - this.clientHeight
  78. if (scrollDistance <= sign) {
  79. binding.value()
  80. }
  81. })
  82. }
  83. })