修改组件中hooks和store的调用方式
This commit is contained in:
@@ -3,9 +3,7 @@
|
||||
<div>
|
||||
<!-- 加载消防站 -->
|
||||
<LoadingPoints
|
||||
v-if="
|
||||
useStatusStore().appLoadingCompleted && fireStationPoints.length > 0
|
||||
"
|
||||
v-if="useStatus.appLoadingCompleted && fireStationPoints.length > 0"
|
||||
:base-points="fireStationPoints"
|
||||
:get-disaster-icon="getDisasterIcon"
|
||||
:prefix="config.prefix.fireStationPointId"
|
||||
@@ -17,11 +15,11 @@
|
||||
<InformationBox
|
||||
:data="fireStationPointDetail as Record<string, any>"
|
||||
:field="field"
|
||||
v-if="useLoadingInformationStore().fireStation.loading"
|
||||
v-if="useLoadingInformation.fireStation.loading"
|
||||
:title="informationBoxTitle"
|
||||
:offset-x="offsetX"
|
||||
:offset-y="offsetY"
|
||||
:key="useLoadingInformationStore().fireStation.id"
|
||||
:key="useLoadingInformation.fireStation.id"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -42,6 +40,10 @@
|
||||
|
||||
const fireStationPoints = ref<Point[]>([]);
|
||||
|
||||
const useStatus = useStatusStore();
|
||||
const useLoadingInformation = useLoadingInformationStore();
|
||||
const useLoadingResource = useLoadingResourceStore();
|
||||
|
||||
// 信息框相关配置
|
||||
const offsetX = ref(0);
|
||||
const offsetY = ref(0);
|
||||
@@ -57,13 +59,13 @@
|
||||
|
||||
// 监听id变化
|
||||
watch(
|
||||
() => useLoadingInformationStore().fireStation.id,
|
||||
() => useLoadingInformation.fireStation.id,
|
||||
async (newId: number) => {
|
||||
if (newId === -1) {
|
||||
return;
|
||||
}
|
||||
// 获取消防站数据
|
||||
const clickObject = useLoadingInformationStore().clickObject;
|
||||
const clickObject = useLoadingInformation.clickObject;
|
||||
|
||||
if (!clickObject || !clickObject.primitive) {
|
||||
console.warn('点击对象或图元不存在');
|
||||
@@ -71,7 +73,7 @@
|
||||
}
|
||||
|
||||
const res = await $api.firefighter.getPointDetailById(
|
||||
useLoadingInformationStore().fireStation.id
|
||||
useLoadingInformation.fireStation.id
|
||||
);
|
||||
|
||||
// 更新数据
|
||||
@@ -87,7 +89,7 @@
|
||||
offsetY.value = screenPos.y;
|
||||
|
||||
// 显示新的信息框
|
||||
useLoadingInformationStore().fireStation.loading = true;
|
||||
useLoadingInformation.fireStation.loading = true;
|
||||
} catch (error) {
|
||||
throw new Error(`坐标转换失败:${error}`);
|
||||
}
|
||||
@@ -96,19 +98,19 @@
|
||||
|
||||
// 监听显示隐藏
|
||||
watch(
|
||||
() => useStatusStore().poiLayers.showFireStation.show,
|
||||
() => useStatus.poiLayers.showFireStation.show,
|
||||
(newValue: boolean) => {
|
||||
if (newValue) {
|
||||
// 显示消防站
|
||||
CesiumUtilsSingleton.batchShowPrimitives(
|
||||
useLoadingResourceStore().getLoadingResource(
|
||||
useLoadingResource.getLoadingResource(
|
||||
LoadingResource.FIRE_STATION
|
||||
).ids
|
||||
);
|
||||
} else {
|
||||
// 隐藏消防站
|
||||
CesiumUtilsSingleton.batchHidePrimitives(
|
||||
useLoadingResourceStore().getLoadingResource(
|
||||
useLoadingResource.getLoadingResource(
|
||||
LoadingResource.FIRE_STATION
|
||||
).ids
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user