import { getDevices, getDevicesAll } from 'apis/index'; const user = { namespaced: true, state: { devices: [], devicesAll: null, }, getters: {}, mutations: { /** * 设置devices数据 * @param {*} state * @param {array} devices */ setDevices(state, devices) { state.devices = devices; }, /** * 设置devicesAll的数据 * @param {*} state * @param {*} devices */ setDevicesAll(state, devices) { state.devicesAll = devices; }, }, actions: { // 获取设备列表(站点列表) async getDevices({ commit }) { try { const data = await getDevices(); commit('setDevices', data || []); return data; } catch (error) { throw new Error(error); } }, // 获取设备列表(站点列表) 完整信息 async getDevicesAll({ commit }) { try { const data = await getDevicesAll(); commit('setDevicesAll', data || null); return data; } catch (error) { throw new Error(error); } }, }, }; export default user;