/* eslint-disable */
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    projectHeaderData: { // 顶部数据
      hidden: true, // 是否隐藏框架
      title: '', // 标题
      btns: [] // 按钮数据：{value: 'icon-shezhi',type: 'icon',response: ()=>{}},{value: '按钮',type: 'word',response: ()=>{}}
    },
    systemType: null // 系统类型判断：IOS/Android/Other
  },
  mutations: {
    setProjectHeader (state, data) { // 设置顶部数据
      data = data || {}
      state.projectHeaderData = {
        hidden: true,
        title: '',
        btns: [],
        ...data
      }
    },
    setSystemType (state) { // 获取系统类型
      var u = navigator.userAgent
      var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1 // android终端
      var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) // ios终端
      state.systemType = isIOS ? 'IOS' : isAndroid ? 'Android' : 'Other'
    }
  }
})
export const modules = {
  newIndex: () => require('./newIndex/index').default
}

Object.keys(modules).forEach((modKey) => {
  const modNS = modKey.split('/')
  const getMod = modules[modKey]
  store.registerModule(...modNS, getMod())
})

export default store
