修改组件中hooks和store的调用方式

This commit is contained in:
wzy-warehouse
2026-05-07 12:53:25 +08:00
parent 2ab1b7da7c
commit 68715dea2b
32 changed files with 350 additions and 261 deletions
@@ -3,10 +3,7 @@
<div>
<!-- 加载避难所 -->
<LoadingPoints
v-if="
useStatusStore().appLoadingCompleted &&
emergencyShelterPoints.length > 0
"
v-if="useStatus.appLoadingCompleted && emergencyShelterPoints.length > 0"
:base-points="emergencyShelterPoints"
:get-disaster-icon="getDisasterIcon"
:prefix="config.prefix.emergencyShelterPointId"
@@ -18,11 +15,11 @@
<InformationBox
:data="emergencyShelterPointDetail as Record<string, any>"
:field="field"
v-if="useLoadingInformationStore().emergencyShelter.loading"
v-if="useLoadingInformation.emergencyShelter.loading"
:title="informationBoxTitle"
:offset-x="offsetX"
:offset-y="offsetY"
:key="useLoadingInformationStore().emergencyShelter.id"
:key="useLoadingInformation.emergencyShelter.id"
/>
</div>
</template>
@@ -43,6 +40,10 @@
const emergencyShelterPoints = ref<Point[]>([]);
const useStatus = useStatusStore();
const useLoadingInformation = useLoadingInformationStore();
const useLoadingResource = useLoadingResourceStore();
// 信息框相关配置
const offsetX = ref(0);
const offsetY = ref(0);
@@ -58,13 +59,13 @@
// 监听id变化
watch(
() => useLoadingInformationStore().emergencyShelter.id,
() => useLoadingInformation.emergencyShelter.id,
async (newId: number) => {
if (newId === -1) {
return;
}
// 获取避难所数据
const clickObject = useLoadingInformationStore().clickObject;
const clickObject = useLoadingInformation.clickObject;
if (!clickObject || !clickObject.primitive) {
console.warn('点击对象或图元不存在');
@@ -72,7 +73,7 @@
}
const res = await $api.emergencyShelter.getPointDetailById(
useLoadingInformationStore().emergencyShelter.id
useLoadingInformation.emergencyShelter.id
);
// 更新数据
@@ -88,7 +89,7 @@
offsetY.value = screenPos.y;
// 显示新的信息框
useLoadingInformationStore().emergencyShelter.loading = true;
useLoadingInformation.emergencyShelter.loading = true;
} catch (error) {
throw new Error(`坐标转换失败:${error}`);
}
@@ -97,19 +98,19 @@
// 监听显示隐藏
watch(
() => useStatusStore().poiLayers.showRefugeeShelter.show,
() => useStatus.poiLayers.showRefugeeShelter.show,
(newValue: boolean) => {
if (newValue) {
// 显示避难所
CesiumUtilsSingleton.batchShowPrimitives(
useLoadingResourceStore().getLoadingResource(
useLoadingResource.getLoadingResource(
LoadingResource.EMERGENCY_SHELTER
).ids
);
} else {
// 隐藏避难所
CesiumUtilsSingleton.batchHidePrimitives(
useLoadingResourceStore().getLoadingResource(
useLoadingResource.getLoadingResource(
LoadingResource.EMERGENCY_SHELTER
).ids
);