import Vue from 'vue'; import { parser } from '@/ibp/utils/parser'; /** * ibp状态数据 */ const ibp = { namespaced: true, state: { ibp: null, // 数据 ibpDevice: {}, // 解析后的地图数据 ibpList: {}, // 数据列表 ibpIdList: {} // 数据列表(以id为标识) }, getters: { ibpList: (state) => { return state.ibpList; }, ibp: (state) => { return state.ibp; }, version: (state) => { if (state.ibp) { return state.ibp.version; } else { return null; } } }, mutations: { ibpRender: (state, devices) => { console.log('--2', devices); Vue.prototype.$ibp && Vue.prototype.$ibp.render(devices); }, setIbpData: (state, ibp) => { state.ibp = ibp; } }, actions: { setIbpData: ({ commit }, ibp) => { commit('setIbpData', ibp); }, updateIbpDevices: ({ commit }, models) => { return new Promise((resolve) => { if (!(models instanceof Array)) { models = [models]; } commit('ibpRender', models); resolve(models); }); } } }; export default ibp;