20251113炳辰版本
This commit is contained in:
93
src/components/vuex/store.js
Normal file
93
src/components/vuex/store.js
Normal file
@@ -0,0 +1,93 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
Vue.use(Vuex)
|
||||
|
||||
export const store = new Vuex.Store({
|
||||
state: {
|
||||
config: {
|
||||
meta: {
|
||||
drawtool: {},
|
||||
position: [],
|
||||
basemap: [],
|
||||
},
|
||||
tables: [],
|
||||
},
|
||||
LocalLocation: {
|
||||
currentPosition: '',
|
||||
currentLocation: ''
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
updateDrawtool(state, drawtool) {
|
||||
//刷新之后 重新赋值 页面数据会丢失
|
||||
let config = sessionStorage["Data"]
|
||||
if (config) {
|
||||
state.config = JSON.parse(config)
|
||||
}
|
||||
|
||||
state.config.meta.drawtool = drawtool
|
||||
sessionStorage["Data"] = JSON.stringify(state.config)
|
||||
},
|
||||
updatePosition1(state, position) {
|
||||
let config = sessionStorage["Data"]
|
||||
if (config) {
|
||||
state.config = JSON.parse(config)
|
||||
}
|
||||
|
||||
state.config.meta.position = position
|
||||
sessionStorage["Data"] = JSON.stringify(state.config)
|
||||
},
|
||||
updateBasemap(state, basemap) {
|
||||
let config = sessionStorage["Data"]
|
||||
if (config) {
|
||||
state.config = JSON.parse(config)
|
||||
}
|
||||
|
||||
state.config.meta.basemap = basemap
|
||||
sessionStorage["Data"] = JSON.stringify(state.config)
|
||||
},
|
||||
updateTables(state, tables) {
|
||||
let config = sessionStorage["Data"]
|
||||
if (config) {
|
||||
state.config = JSON.parse(config)
|
||||
}
|
||||
|
||||
state.config.tables = tables
|
||||
sessionStorage["Data"] = JSON.stringify(state.config)
|
||||
},
|
||||
updateData(state, config) {
|
||||
state.config = config
|
||||
},
|
||||
updateLocation(state, location) {
|
||||
state.LocalLocation.currentLocation = location
|
||||
},
|
||||
updatePosition(state, position) {
|
||||
state.LocalLocation.currentPosition = position
|
||||
}
|
||||
|
||||
},
|
||||
actions: {
|
||||
updateDrawtool({ commit, state }, obj) {
|
||||
commit('updateDrawtool', obj.drawtool)
|
||||
},
|
||||
updatePosition1({ commit, state }, obj) {
|
||||
commit('updatePosition1', obj.position)
|
||||
},
|
||||
updateBasemap({ commit, state }, obj) {
|
||||
commit('updateBasemap', obj.basemap)
|
||||
},
|
||||
updateTables({ commit, state }, obj) {
|
||||
commit("updateTables", obj.tables)
|
||||
},
|
||||
updateData({ commit, state }, obj) {
|
||||
commit("updateData", obj.config)
|
||||
},
|
||||
updateLocation({ commit, state }, obj) {
|
||||
commit("updateLocation", obj.location)
|
||||
},
|
||||
updatePosition({ commit, state }, obj) {
|
||||
commit("updatePosition", obj.position)
|
||||
}
|
||||
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user