main.js 939 B

1234567891011121314151617181920212223242526272829303132333435
  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 './utils/filter'
  9. import './assets/styles/icon.scss'
  10. // 全站配置
  11. window.SITE_CONFIG = {}
  12. Vue.prototype.$refreshTitle = refreshTitle
  13. Vue.directive('myBlur', {
  14. inserted: function (element) {
  15. element.onblur = function () {
  16. const timer = setTimeout(function () {
  17. clearTimeout(timer)
  18. const scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0
  19. window.scrollTo(0, Math.max(scrollHeight - 1, 0))
  20. }, 100)
  21. }
  22. }
  23. })
  24. Vue.use(VueCookie)
  25. new Vue({
  26. router,
  27. store,
  28. render: h => h(App),
  29. created () {
  30. // 保存整站vuex本地储存初始状态
  31. window.SITE_CONFIG.storeState = cloneDeep(store.state)
  32. }
  33. }).$mount('#app')