store.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. Vue.use(Vuex)
  4. const store = new Vuex.Store({
  5. state: {
  6. wholeSituationBackStageIp:'192.168.0.91',//117.78.18.24
  7. wholeSituationBackStagePort:'9988',
  8. GlobalLocalIp:'192.168.0.91',//192.168.1.102
  9. GlobalLocalPort:'9987',
  10. windpowerstationNameToId:{},
  11. default_wpid:'0',
  12. default_wpname:'宁夏新能源公司',
  13. default_weather_wpid:'CL_FDC',
  14. default_tourist:'2',
  15. default_tourist_wpid:'CL_FDC',
  16. default_tourist_wpname:'麻黄山风电场',
  17. memberData:'',
  18. initName:''
  19. },
  20. mutations: {
  21. copy(state,cont){
  22. //单一的改变某一个变量
  23. console.log(state)
  24. console.log(cont)
  25. state.memberData = cont;
  26. },
  27. change(state,contObj){
  28. //通过传入的变量去改变对应的全局变量
  29. let str = contObj.str;
  30. let cont = contObj.cont;
  31. state[str] = cont;
  32. },
  33. },
  34. actions:{
  35. copeFun:function(context,mData){
  36. context.commit('copy',mData)
  37. },
  38. changeFun:function(context,obj){
  39. context.commit('change',obj)
  40. }
  41. }
  42. })
  43. export default store