import Vue from 'vue'
import VueRouter from 'vue-router'
import Vuex from 'vuex'
import App from './App.vue'
import './public/apis' // 接口请求配置
import createStore from './store' // Vuex
import createRouter from './router/router'
import UsePlugin from 'runner/common/plugins'
import customPlugin from './public/plugins'
import utils from 'utils'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

Vue.use(Vuex)
Vue.use(VueRouter)
Vue.use(UsePlugin)
Vue.use(customPlugin)
Vue.use(ElementUI)

const router = createRouter() // 创建router
const store = createStore() // 创建Vuex

// 监听窗口缩放事件
const winResizeFn = utils.throttle(function () {
    const innerWH = {
        innerWidth: window.innerWidth,
        innerHeight: window.innerHeight
    }

    store.dispatch('setInnerWH', innerWH)
})

window.addEventListener('resize', winResizeFn)

new Vue({
    el: '#app',
    router,
    store,
    UsePlugin,
    customPlugin,
    template: '<App/>',
    components: { App }
})
