main.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import Vue from 'vue'
  2. import App from './App.vue'
  3. import router from './router'
  4. import store from './store'
  5. import cloneDeep from 'lodash/cloneDeep'
  6. import VueCookie from 'vue-cookie'
  7. import refreshTitle from './utils/refreshTitle'
  8. import * as echarts from 'echarts'
  9. import { BarChart, PieChart } from 'echarts/charts'
  10. import './utils/filter'
  11. import './assets/styles/icon.scss'
  12. // 全站配置
  13. window.SITE_CONFIG = {}
  14. Vue.prototype.$refreshTitle = refreshTitle
  15. Vue.prototype.$echarts = echarts
  16. Vue.directive('myBlur', {
  17. inserted: function (element) {
  18. element.onblur = function () {
  19. const timer = setTimeout(function () {
  20. clearTimeout(timer)
  21. const scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0
  22. window.scrollTo(0, Math.max(scrollHeight - 1, 0))
  23. }, 100)
  24. }
  25. }
  26. })
  27. Vue.use(VueCookie)
  28. echarts.use(
  29. [BarChart, PieChart]
  30. )
  31. new Vue({
  32. router,
  33. store,
  34. render: h => h(App),
  35. created () {
  36. // 保存整站vuex本地储存初始状态
  37. window.SITE_CONFIG.storeState = cloneDeep(store.state)
  38. }
  39. }).$mount('#app')