Files
gd-earth/src/stores/position.js

27 lines
483 B
JavaScript

import { defineStore } from 'pinia'
import { isLnglat } from '/@/api/util'
export const usePositionStore = defineStore({
id: 'position',
state: () => ({
lng: NaN,
lat: NaN,
change:true,
}),
getters: {
value: (state) => { state.lng, state.lat }
},
actions: {
set(position) {
if ( !isLnglat(position) ) return false
this.lng = position.lng
this.lat = position.lat
this.change = !this.change
return true
},
},
})