From f0b3ef4bb208a93b8ef56176730823feb8b9f53b Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Wed, 09 Apr 2025 09:56:31 +0800
Subject: [PATCH] feat: 用户行政区划中心点

---
 src/store/modules/user.js                             |    2 ++
 src/store/modules/home.js                             |   13 +++++++++++++
 src/views/Home/useMapAggregation/useMapAggregation.js |   13 +++++++++++++
 3 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/src/store/modules/home.js b/src/store/modules/home.js
index 16eea68..0c96d8c 100644
--- a/src/store/modules/home.js
+++ b/src/store/modules/home.js
@@ -1,9 +1,14 @@
 import { set } from 'lodash'
 import { EDeviceTypeName } from '@/utils/staticData/enums'
+import { getStore, setStore } from '@/utils/store'
 
 const home = {
   state: {
     machineNestDetail: false, // 机巢详情
+		// 用户行政区划中心点
+		userAreaPosition: getStore({ name: 'userAreaPosition' }) || {},
+		// 用户切换后行政区划中心点
+		currentAreaPosition:getStore({ name: 'currentAreaPosition' }) || {},
     singleUavHome: {},
 		footActiveIndex: 0,
 		isEventOverviewDetail: false,//是事件概述详情
@@ -38,6 +43,14 @@
   },
   actions: {},
   mutations: {
+		setUserAreaPosition: (state, data) => {
+			setStore({ name: 'userAreaPosition', content: data })
+			state.userAreaPosition = data;
+		},
+		setCurrentAreaPosition: (state, data) => {
+			setStore({ name: 'currentAreaPosition', content: data })
+			state.currentAreaPosition = data;
+		},
 		setFootActiveIndex: (state, index) => {
 			state.footActiveIndex = index;
 		},
diff --git a/src/store/modules/user.js b/src/store/modules/user.js
index 9d50b4d..a961939 100644
--- a/src/store/modules/user.js
+++ b/src/store/modules/user.js
@@ -235,6 +235,8 @@
 						commit('SET_ROLES', [])
 						commit('DEL_ALL_TAG', [])
 						commit('CLEAR_LOCK')
+						commit('setUserAreaPosition',{})
+						commit('setCurrentAreaPosition',{})
 						removeToken()
 						removeRefreshToken()
 						removeToken()
diff --git a/src/views/Home/useMapAggregation/useMapAggregation.js b/src/views/Home/useMapAggregation/useMapAggregation.js
index 432d330..8a00691 100644
--- a/src/views/Home/useMapAggregation/useMapAggregation.js
+++ b/src/views/Home/useMapAggregation/useMapAggregation.js
@@ -208,9 +208,22 @@
     const outlineGJson = await getOutLine(jsonPathPre, hierarchy)
     scalingJudgment.forEach(item => item.show && (item.outline = outlineGJson))
     const [longitude, latitude] = outlineGJson.features[0].properties.centroid
+    setCenterPosition({longitude, latitude})
     flyTo({ longitude, latitude }, 0, scalingJudgment[(hierarchy.length - 3) * (-1)].height)
   }
 
+  const userAreaPosition = computed(() => store.state.home.userAreaPosition);
+  const currentAreaPosition = computed(() => store.state.home.currentAreaPosition);
+
+  const setCenterPosition = (position) => {
+    store.commit('setCurrentAreaPosition', position)
+		if (!userAreaPosition.value.longitude){
+			store.commit('setUserAreaPosition', position)
+		}
+  }
+
+
+
   watch(
     selectedAreaCode,
     async (newValue, oldValue) => {

--
Gitblit v1.9.3