import { createStore } from 'vuex'

// 创建一个新的 store 实例
const store = createStore({
     // 值的存储  获取: this.$store.state.xxxx
     state() {
          return {
               windturbinelist: Object,  // 服务器推送的风机详细信息
               warning: Object,
               suggestion: [],
               titleInfo: Object,
               current: 1,
          }
     },

     //计算state的值  获取: this.$store.getters.xxxx
     getters: {
          windturbinelist(state) {
               return state.windturbinelist;
          },
          current(state) {
               return state.current;
          },
     },

     // 数据更新 使用: this.$store.commit('函数名','val')
     mutations: {
          windturbinelist(state, data) {
               state.windturbinelist = data;
          },
          warning(state, data) {
               state.warning = data;
          },
          suggestion(state, data) {
               state.suggestion = data;
          },
          titleInfo(state, data) {
               state.titleInfo = data;
          },
          current(state, data) {
               state.current = data;
          },
     }
})

export default store