增加vuex 禁飞区数据 缓存

This commit is contained in:
oldHome 2025-06-04 00:29:41 +08:00
parent 9d240362ab
commit c6764c9e2e
3 changed files with 22 additions and 32 deletions

View File

@ -17,6 +17,7 @@ const store = new Vuex.Store({
airList: [], // 所有飞机列表
siteList: [], // 站点列表
routeList: [], // 航线列表
noflyData: [], // 禁飞区数据
categoryList: [], // 分类列表(小程序)
spuList: [], // 商品spu列表
skuList: [], // 商品sku列表
@ -64,6 +65,12 @@ const store = new Vuex.Store({
setRouteList (state, list) {
state.routeList = list
},
/**
* @description: 设置禁飞区列表
*/
setNoflyData (state, data) {
state.noflyData = data
},
/**
* @description: 设置分类列表
*/
@ -582,6 +589,19 @@ const store = new Vuex.Store({
})
}
},
/**
* @description: 获取禁飞区数据
*/
async fetchNoflyData ({ commit }) {
const res = await api.get('getNoflyData')
if (res.data.status === 1) {
commit('setNoflyData', res.data.noflyData)
} else {
commit('setNoflyData', {})
Message.warning(res.data.msg)
}
return res.data.routeData
},
/**
* @description: 获取分类列表
* @return {*} 列表

View File

@ -17,9 +17,6 @@ export default {
MapBox
},
computed: {
airList () {
return this.$store.state.airList
},
/**
* @description: 侧边栏显隐
*/
@ -28,39 +25,11 @@ export default {
}
},
methods: {
/**
* @description: 创建飞机图标
*/
makePlanes (planes) {
this.$refs.mapbox.removePlanes()//
planes.forEach((plane, index) => { //
let planeDefaultLonLat
if (localStorage.getItem(plane.name) !== null) { //
planeDefaultLonLat = JSON.parse(localStorage.getItem(plane.name))
plane.lon = planeDefaultLonLat.lon
plane.lat = planeDefaultLonLat.lat
} else {
plane.lon = 0
plane.lat = 0
}
this.$refs.mapbox.makePlane(plane, index)
})
}
},
mounted () {
if (this.airList.length > 0) {
this.makePlanes(this.airList)//
}
},
watch: {
/**
* @description: 飞机列表更新时候 更新地图
*/
airList: {
handler (val) {
this.makePlanes(val)
}
},
/**
* @description: 侧边栏缩进有变化时 地图重新自适应
*/

View File

@ -64,6 +64,7 @@ export default {
this.$store.dispatch('fetchAdminList')//
this.$store.dispatch('fetchSiteList')//
this.$store.dispatch('fetchRouteList')// 线
this.$store.dispatch('fetchNoflyData')//
this.$store.dispatch('fetchCategoryList')//
this.$store.dispatch('fetchSpuList')// spu
this.$store.dispatch('fetchSkuList')// sku