import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import 'xe-utils'
import '@/css/index.css'
import VXETable from 'vxe-table'
import "@/css/vxe-table/source-index.css"
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import '@/font-icon/iconfont.css'
import i18n from '@/util/translate'
import '@/util/init-data'
import '@/util/vue-global/index'

Vue.prototype.$myFleet = []
const config = require('../public/config/sys-config.json')
window.localStorage.setItem('pgName', config.projectName)
Vue.use(VXETable)
Vue.use(ElementUI)
Vue.config.productionTip = false

Object.keys(store.state).forEach((item: string) => {
  const data = {
    data: null,
    type: item
  }
  store.commit('setDataNull', data)
})

function getParam(name: string) {
  let result: any = null
  let paramStr: string[] = []
  let params: string[] = []
  if (location.hash.indexOf('?') !== -1) {
    paramStr = location.hash.split('?')
  }
  if (paramStr.length) {
    params = paramStr[1].split('&')
  }

  for (let i = 0; i < params.length; i++) {
    const str = params[i]
    if (str.indexOf(name) !== -1) {
      const p = str.split('=')
      result = p[1]
      break
    }
  }
  return result
}

document.title = config.title

new Vue({
  router,
  i18n,
  store,
  render: h => h(App)
}).$mount('#app')
