111
k94314517
2025-06-18 153404ffa0a9c6d23d2c2732b46fa6929e86294f
h5/store/index.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,34 @@
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const userInfo = uni.getStorageSync('userInfo');
const store = new Vuex.Store({
   state: {
      userInfo: userInfo || null     // ç”¨æˆ·ä¿¡æ¯
   },
   mutations: {
      // è®¾ç½®ç”¨æˆ·ä¿¡æ¯
      setUserInfo(state, val) {
         state.userInfo = val
         uni.setStorageSync('userInfo', val);
      }
   },
   actions: {
      // èŽ·å–çŠ¶æ€é«˜åº¦
      getHeight(context) {
         let res = uni.getMenuButtonBoundingClientRect()
         let status = uni.getSystemInfoSync()
         var height = res.height
         let statusbarHeight = status.statusBarHeight
         let navHeight = res.height + (res.top - statusbarHeight) * 2;
         context.commit('setHeight', { statusbarHeight, navHeight, height })
      }
   }
})
export default store;