Files
global-navigation-satellite…/src/render/api/entity.js

23 lines
695 B
JavaScript
Raw Normal View History

2025-12-31 15:17:05 +08:00
import store from '../store';
2021-12-22 19:32:34 +08:00
2025-12-31 15:17:05 +08:00
let entities = [];
2021-12-22 19:32:34 +08:00
const load = (value) => {
2025-12-31 15:17:05 +08:00
entities = value;
2021-12-22 19:32:34 +08:00
// 将卫星状态信息存储到store中
2025-12-31 15:17:05 +08:00
const satellites = filter('Satellite');
const satellite_state_arr = satellites.map(({ description, id, show }) => { return { description: description._value, id, show } });
2021-12-23 11:16:54 +08:00
store.dispatch('satelliteSystem/setSatellites', {
satellites: satellite_state_arr
2025-12-31 15:17:05 +08:00
});
};
2021-12-22 19:32:34 +08:00
2025-12-31 15:17:05 +08:00
const get = id => entities.find(entity => entity.id === id);
2021-12-22 19:32:34 +08:00
2025-12-31 15:17:05 +08:00
const find = keyword => entities.find(entity => entity.id.startsWith(keyword));
2021-12-22 19:32:34 +08:00
2025-12-31 15:17:05 +08:00
const filter = keyword => entities.filter(entity => entity.id.startsWith(keyword));
2021-12-22 19:32:34 +08:00
2025-12-31 15:17:05 +08:00
export default { get, load, find };