screen.js 1001 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { defineStore } from 'pinia'
  2. import { reactive, ref } from 'vue'
  3. export const useScreenStore = defineStore('screen',() => {
  4. const controllerData = reactive({})
  5. let placeList = []
  6. const tunnelList = reactive([])
  7. const currentTunnel = ref({})
  8. const setController = (val) => {
  9. Object.assign(controllerData, val)
  10. }
  11. const setTunnelList = (val) => {
  12. placeList.length = 0;
  13. val.list.forEach(item => {
  14. placeList.push({
  15. styleId: item.ID,
  16. position: { lat: item.latitude, lng: item.longitude } ,
  17. })
  18. })
  19. tunnelList.length = 0
  20. tunnelList.push(...val.list)
  21. }
  22. const setCurrentTunnel = (val) => {
  23. currentTunnel.value = val
  24. console.log('执行2', currentTunnel.value)
  25. }
  26. return {
  27. controllerData,
  28. setController,
  29. tunnelList,
  30. setTunnelList,
  31. placeList,
  32. currentTunnel,
  33. setCurrentTunnel
  34. }
  35. })