修改组件中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,7 +3,7 @@
<div>
<!-- 加载桥梁点 -->
<LoadingPoints
v-if="useStatusStore().appLoadingCompleted && bridgeList.length > 0"
v-if="useStatus.appLoadingCompleted && bridgeList.length > 0"
:base-points="bridgeList"
:get-disaster-icon="getDisasterIcon"
:prefix="config.prefix.bridgePointId"
@@ -15,11 +15,11 @@
<InformationBox
:data="storePointDetail as Record<string, any>"
:field="field"
v-if="useLoadingInformationStore().bridge.loading"
v-if="useLoadingInformation.bridge.loading"
:title="informationBoxTitle"
:offset-x="offsetX"
:offset-y="offsetY"
:key="useLoadingInformationStore().bridge.id"
:key="useLoadingInformation.bridge.id"
/>
</div>
</template>
@@ -40,6 +40,10 @@
const bridgeList = ref<Point[]>([]);
const useStatus = useStatusStore();
const useLoadingInformation = useLoadingInformationStore();
const useLoadingResource = useLoadingResourceStore();
// 信息框相关配置
const offsetX = ref(0);
const offsetY = ref(0);
@@ -55,13 +59,13 @@
// 监听id变化
watch(
() => useLoadingInformationStore().bridge.id,
() => useLoadingInformation.bridge.id,
async (newId: number) => {
if (newId === -1) {
return;
}
// 获取桥梁点数据
const clickObject = useLoadingInformationStore().clickObject;
const clickObject = useLoadingInformation.clickObject;
if (!clickObject || !clickObject.primitive) {
console.warn('点击对象或图元不存在');
@@ -69,7 +73,7 @@
}
const res = await $api.bridges.getPointDetailById(
useLoadingInformationStore().bridge.id
useLoadingInformation.bridge.id
);
// 更新数据
@@ -85,7 +89,7 @@
offsetY.value = screenPos.y;
// 显示新的信息框
useLoadingInformationStore().bridge.loading = true;
useLoadingInformation.bridge.loading = true;
} catch (error) {
throw new Error(`坐标转换失败:${error}`);
}
@@ -94,18 +98,18 @@
// 监听显示隐藏
watch(
() => useStatusStore().infrastructureLayers.showBridge.show,
() => useStatus.infrastructureLayers.showBridge.show,
(newValue: boolean) => {
if (newValue) {
// 显示桥梁点
CesiumUtilsSingleton.batchShowPrimitives(
useLoadingResourceStore().getLoadingResource(LoadingResource.BRIDGE)
useLoadingResource.getLoadingResource(LoadingResource.BRIDGE)
.ids
);
} else {
// 隐藏桥梁点
CesiumUtilsSingleton.batchHidePrimitives(
useLoadingResourceStore().getLoadingResource(LoadingResource.BRIDGE)
useLoadingResource.getLoadingResource(LoadingResource.BRIDGE)
.ids
);
}