// store/index.js import Vue from 'vue' import Vuex from 'vuex' Vue.use(Vuex) export default new Vuex.Store({ state: { bleConnected: false, bleLoading: false, bleError: null, bleData: null, // 新增:用于保存接收到的蓝牙数据 }, mutations: { SET_BLE_CONNECTED(state, status) { state.bleConnected = status }, SET_BLE_LOADING(state, status) { state.bleLoading = status }, SET_BLE_ERROR(state, error) { state.bleError = error }, SET_BLE_DATA(state, data) { state.bleData = data } }, actions: { updateBleConnected({ commit }, status) { commit('SET_BLE_CONNECTED', status) }, updateBleLoading({ commit }, status) { commit('SET_BLE_LOADING', status) }, updateBleError({ commit }, error) { commit('SET_BLE_ERROR', error) }, updateBleData({ commit }, data) { commit('SET_BLE_DATA', data) } }, getters: { bleConnected: state => state.bleConnected, bleLoading: state => state.bleLoading, bleError: state => state.bleError, bleData: state => state.bleData } })