import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import cloneDeep from 'lodash/cloneDeep'
import VueCookie from 'vue-cookie'
import refreshTitle from './utils/refreshTitle'
import './utils/filter'
// 全站配置
window.SITE_CONFIG = {}
Vue.prototype.$refreshTitle = refreshTitle
Vue.directive('myBlur', {
  inserted: function (element) {
    element.onblur = function () {
      const timer = setTimeout(function () {
        clearTimeout(timer)
        const scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0
        window.scrollTo(0, Math.max(scrollHeight - 1, 0))
      }, 100)
    }
  }
})

Vue.use(VueCookie)

new Vue({
  router,
  store,
  render: h => h(App),
  created () {
    // 保存整站vuex本地储存初始状态
    window.SITE_CONFIG.storeState = cloneDeep(store.state)
  }
}).$mount('#app')
