Ver código fonte

🎨 优化地图定位刷新问题

快乐的梦鱼 1 mês atrás
pai
commit
1ca105cd7e

+ 5 - 1
src/pages/home/components/LightMap.vue

@@ -106,7 +106,7 @@ import { getCurrentInstance, onMounted, ref, watch } from 'vue';
 import { assertNotNull, waitTimeOut } from '@imengyu/imengyu-utils';
 import { toast } from '@/components/dialog/CommonRoot';
 import { useSimpleDataLoader } from '@/components/composeabe/loader/SimpleDataLoader';
-import LightVillageApi, { VillageListItem, type VillageMapItem } from '@/api/light/LightVillageApi';
+import LightVillageApi, { type VillageMapItem } from '@/api/light/LightVillageApi';
 import AppCofig from '@/common/config/AppCofig';
 import SimpleDropDownPicker from '@/common/components/SimpleDropDownPicker.vue';
 import NButton from '@/components/basic/Button.vue';
@@ -416,6 +416,10 @@ onMounted(async () => {
 
 defineExpose({
   showSearch,
+  reload: async () => {
+    await regionLoader.reload();
+    loadFirstRegion();
+  }
 });
 </script>
 

+ 7 - 1
src/pages/home/light/map.vue

@@ -88,7 +88,13 @@ const { querys } = useLoadQuerys({
 });
 
 const currentLocation = useGetCurrentLocation({
-  onCityChanged: () => {},
+  onCityChanged: (city, code, district) => {
+    currentCity.value = city;
+    currentCityCode.value = code;
+    currentDistrict.value = district || '';
+    if (district)
+      setTimeout(() => lightMap.value?.reload(), 100);
+  },
 });
 
 const joinDialog = ref<InstanceType<typeof JoinDialog>>();