修改组件中store的调用方式

This commit is contained in:
wzy-warehouse
2026-05-07 13:59:14 +08:00
parent ce6200389c
commit 4b55283ff6
32 changed files with 299 additions and 303 deletions
@@ -3,7 +3,7 @@
<div>
<!-- 加载泥石流隐患点 -->
<LoadingPoints
v-if="useStatus.appLoadingCompleted && debrisFlowPoints.length > 0"
v-if="statusStore.appLoadingCompleted && debrisFlowPoints.length > 0"
:base-points="debrisFlowPoints"
:get-disaster-icon="getDisasterIcon"
:prefix="config.prefix.debrisFlowHiddenPointId"
@@ -15,11 +15,11 @@
<InformationBox
:data="debrisFlowPointDetail as Record<string, any>"
:field="field"
v-if="useLoadingInformation.debrisFlowHiddenPoint.loading"
v-if="loadingInformationStore.debrisFlowHiddenPoint.loading"
:title="informationBoxTitle"
:offset-x="offsetX"
:offset-y="offsetY"
:key="useLoadingInformation.debrisFlowHiddenPoint.id"
:key="loadingInformationStore.debrisFlowHiddenPoint.id"
/>
</div>
</template>
@@ -44,9 +44,9 @@
const debrisFlowPoints = ref<Point[]>([]);
const useStatus = useStatusStore();
const useLoadingInformation = useLoadingInformationStore();
const useLoadingResource = useLoadingResourceStore();
const statusStore = useStatusStore();
const loadingInformationStore = useLoadingInformationStore();
const loadingResourceStore = useLoadingResourceStore();
const { field, getDisasterIcon } = useHiddenPoint();
@@ -65,13 +65,13 @@
// 监听id变化
watch(
() => useLoadingInformation.debrisFlowHiddenPoint.id,
() => loadingInformationStore.debrisFlowHiddenPoint.id,
async (newId: number) => {
if (newId === -1) {
return;
}
// 获取泥石流隐患点数据
const clickObject = useLoadingInformation.clickObject;
const clickObject = loadingInformationStore.clickObject;
if (!clickObject || !clickObject.primitive) {
console.warn('点击对象或图元不存在');
@@ -79,7 +79,7 @@
}
const res = await $api.hiddenDangerSpots.getPointDetailById(
useLoadingInformation.debrisFlowHiddenPoint.id
loadingInformationStore.debrisFlowHiddenPoint.id
);
// 更新数据
@@ -95,7 +95,7 @@
offsetY.value = screenPos.y;
// 显示新的信息框
useLoadingInformation.debrisFlowHiddenPoint.loading = true;
loadingInformationStore.debrisFlowHiddenPoint.loading = true;
} catch (error) {
throw new Error(`坐标转换失败:${error}`);
}
@@ -104,19 +104,19 @@
// 监听显示隐藏
watch(
() => useStatus.poiLayers.showDebrisFlowHiddenPoint.show,
() => statusStore.poiLayers.showDebrisFlowHiddenPoint.show,
(newValue: boolean) => {
if (newValue) {
// 显示泥石流隐患点
CesiumUtilsSingleton.batchShowPrimitives(
useLoadingResource.getLoadingResource(
loadingResourceStore.getLoadingResource(
LoadingResource.DEBRIS_FLOW_HIDDEN_POINT
).ids
);
} else {
// 隐藏泥石流隐患点
CesiumUtilsSingleton.batchHidePrimitives(
useLoadingResource.getLoadingResource(
loadingResourceStore.getLoadingResource(
LoadingResource.DEBRIS_FLOW_HIDDEN_POINT
).ids
);
@@ -3,7 +3,7 @@
<div>
<!-- 加载山洪隐患点 -->
<LoadingPoints
v-if="useStatus.appLoadingCompleted && flashFloodPoints.length > 0"
v-if="statusStore.appLoadingCompleted && flashFloodPoints.length > 0"
:base-points="flashFloodPoints"
:get-disaster-icon="getDisasterIcon"
:prefix="config.prefix.flashFloodHiddenPointId"
@@ -15,11 +15,11 @@
<InformationBox
:data="flashFloodPointDetail as Record<string, any>"
:field="field"
v-if="useLoadingInformation.flashFloodHiddenPoint.loading"
v-if="loadingInformationStore.flashFloodHiddenPoint.loading"
:title="informationBoxTitle"
:offset-x="offsetX"
:offset-y="offsetY"
:key="useLoadingInformation.flashFloodHiddenPoint.id"
:key="loadingInformationStore.flashFloodHiddenPoint.id"
/>
</div>
</template>
@@ -44,9 +44,9 @@
const flashFloodPoints = ref<Point[]>([]);
const useStatus = useStatusStore();
const useLoadingInformation = useLoadingInformationStore();
const useLoadingResource = useLoadingResourceStore();
const statusStore = useStatusStore();
const loadingInformationStore = useLoadingInformationStore();
const loadingResourceStore = useLoadingResourceStore();
const { field, getDisasterIcon } = useHiddenPoint();
@@ -65,13 +65,13 @@
// 监听id变化
watch(
() => useLoadingInformation.flashFloodHiddenPoint.id,
() => loadingInformationStore.flashFloodHiddenPoint.id,
async (newId: number) => {
if (newId === -1) {
return;
}
// 获取山洪隐患点数据
const clickObject = useLoadingInformation.clickObject;
const clickObject = loadingInformationStore.clickObject;
if (!clickObject || !clickObject.primitive) {
console.warn('点击对象或图元不存在');
@@ -79,7 +79,7 @@
}
const res = await $api.hiddenDangerSpots.getPointDetailById(
useLoadingInformation.flashFloodHiddenPoint.id
loadingInformationStore.flashFloodHiddenPoint.id
);
// 更新数据
@@ -95,7 +95,7 @@
offsetY.value = screenPos.y;
// 显示新的信息框
useLoadingInformation.flashFloodHiddenPoint.loading = true;
loadingInformationStore.flashFloodHiddenPoint.loading = true;
} catch (error) {
throw new Error(`坐标转换失败:${error}`);
}
@@ -104,19 +104,19 @@
// 监听显示隐藏
watch(
() => useStatus.poiLayers.showFlashFloodHiddenPoint.show,
() => statusStore.poiLayers.showFlashFloodHiddenPoint.show,
(newValue: boolean) => {
if (newValue) {
// 显示山洪隐患点
CesiumUtilsSingleton.batchShowPrimitives(
useLoadingResource.getLoadingResource(
loadingResourceStore.getLoadingResource(
LoadingResource.FLASH_FLOOD_HIDDEN_POINT
).ids
);
} else {
// 隐藏山洪隐患点
CesiumUtilsSingleton.batchHidePrimitives(
useLoadingResource.getLoadingResource(
loadingResourceStore.getLoadingResource(
LoadingResource.FLASH_FLOOD_HIDDEN_POINT
).ids
);
@@ -3,7 +3,7 @@
<div>
<!-- 加载滑坡隐患点 -->
<LoadingPoints
v-if="useStatus.appLoadingCompleted && landslidePoints.length > 0"
v-if="statusStore.appLoadingCompleted && landslidePoints.length > 0"
:base-points="landslidePoints"
:get-disaster-icon="getDisasterIcon"
:prefix="config.prefix.landslideHiddenPointId"
@@ -15,11 +15,11 @@
<InformationBox
:data="landslidePointDetail as Record<string, any>"
:field="field"
v-if="useLoadingInformation.landslideHiddenPoint.loading"
v-if="loadingInformationStore.landslideHiddenPoint.loading"
:title="informationBoxTitle"
:offset-x="offsetX"
:offset-y="offsetY"
:key="useLoadingInformation.landslideHiddenPoint.id"
:key="loadingInformationStore.landslideHiddenPoint.id"
/>
</div>
</template>
@@ -44,9 +44,9 @@
const landslidePoints = ref<Point[]>([]);
const useStatus = useStatusStore();
const useLoadingInformation = useLoadingInformationStore();
const useLoadingResource = useLoadingResourceStore();
const statusStore = useStatusStore();
const loadingInformationStore = useLoadingInformationStore();
const loadingResourceStore = useLoadingResourceStore();
const { field, getDisasterIcon } = useHiddenPoint();
@@ -65,13 +65,13 @@
// 监听id变化
watch(
() => useLoadingInformation.landslideHiddenPoint.id,
() => loadingInformationStore.landslideHiddenPoint.id,
async (newId: number) => {
if (newId === -1) {
return;
}
// 获取滑坡隐患点数据
const clickObject = useLoadingInformation.clickObject;
const clickObject = loadingInformationStore.clickObject;
if (!clickObject || !clickObject.primitive) {
console.warn('点击对象或图元不存在');
@@ -79,7 +79,7 @@
}
const res = await $api.hiddenDangerSpots.getPointDetailById(
useLoadingInformation.landslideHiddenPoint.id
loadingInformationStore.landslideHiddenPoint.id
);
// 更新数据
@@ -95,7 +95,7 @@
offsetY.value = screenPos.y;
// 显示新的信息框
useLoadingInformation.landslideHiddenPoint.loading = true;
loadingInformationStore.landslideHiddenPoint.loading = true;
} catch (error) {
throw new Error(`坐标转换失败:${error}`);
}
@@ -104,19 +104,19 @@
// 监听显示隐藏
watch(
() => useStatus.poiLayers.showLandslideHiddenPoint.show,
() => statusStore.poiLayers.showLandslideHiddenPoint.show,
(newValue: boolean) => {
if (newValue) {
// 显示滑坡隐患点
CesiumUtilsSingleton.batchShowPrimitives(
useLoadingResource.getLoadingResource(
loadingResourceStore.getLoadingResource(
LoadingResource.LANDSLIDE_HIDDEN_POINT
).ids
);
} else {
// 隐藏滑坡隐患点
CesiumUtilsSingleton.batchHidePrimitives(
useLoadingResource.getLoadingResource(
loadingResourceStore.getLoadingResource(
LoadingResource.LANDSLIDE_HIDDEN_POINT
).ids
);
@@ -3,7 +3,7 @@
<div>
<!-- 加载风险点 -->
<LoadingPoints
v-if="useStatus.appLoadingCompleted && riskPoints.length > 0"
v-if="statusStore.appLoadingCompleted && riskPoints.length > 0"
:base-points="riskPoints"
:get-disaster-icon="getDisasterIcon"
:prefix="config.prefix.riskPointId"
@@ -15,11 +15,11 @@
<InformationBox
:data="riskPointDetail as Record<string, any>"
:field="field"
v-if="useLoadingInformation.riskPoint.loading"
v-if="loadingInformationStore.riskPoint.loading"
:title="informationBoxTitle"
:offset-x="offsetX"
:offset-y="offsetY"
:key="useLoadingInformation.riskPoint.id"
:key="loadingInformationStore.riskPoint.id"
/>
</div>
</template>
@@ -40,9 +40,9 @@
const riskPoints = ref<Point[]>([]);
const useStatus = useStatusStore();
const useLoadingInformation = useLoadingInformationStore();
const useLoadingResource = useLoadingResourceStore();
const statusStore = useStatusStore();
const loadingInformationStore = useLoadingInformationStore();
const loadingResourceStore = useLoadingResourceStore();
// 信息框相关配置
const offsetX = ref(0);
@@ -58,13 +58,13 @@
// 监听id变化
watch(
() => useLoadingInformation.riskPoint.id,
() => loadingInformationStore.riskPoint.id,
async (newId: number) => {
if (newId === -1) {
return;
}
// 获取风险点数据
const clickObject = useLoadingInformation.clickObject;
const clickObject = loadingInformationStore.clickObject;
if (!clickObject || !clickObject.primitive) {
console.warn('点击对象或图元不存在');
@@ -72,7 +72,7 @@
}
const res = await $api.riskSpots.getPointDetailById(
useLoadingInformation.riskPoint.id
loadingInformationStore.riskPoint.id
);
// 更新数据
@@ -87,7 +87,7 @@
offsetY.value = screenPos.y;
// 显示新的信息框
useLoadingInformation.riskPoint.loading = true;
loadingInformationStore.riskPoint.loading = true;
} catch (error) {
throw new Error(`坐标转换失败:${error}`);
}
@@ -96,17 +96,17 @@
// 监听显示隐藏风险点
watch(
() => useStatus.mapLayers.riskPointShow.show,
() => statusStore.mapLayers.riskPointShow.show,
(newValue: boolean) => {
if (newValue) {
CesiumUtilsSingleton.batchShowPrimitives(
useLoadingResource.getLoadingResource(
loadingResourceStore.getLoadingResource(
LoadingResource.RISK_POINT
).ids
);
} else {
CesiumUtilsSingleton.batchHidePrimitives(
useLoadingResource.getLoadingResource(
loadingResourceStore.getLoadingResource(
LoadingResource.RISK_POINT
).ids
);
@@ -4,7 +4,7 @@
<!-- 加载内涝隐患点 -->
<LoadingPoints
v-if="
useStatus.appLoadingCompleted && waterLoggingPoints.length > 0
statusStore.appLoadingCompleted && waterLoggingPoints.length > 0
"
:base-points="waterLoggingPoints"
:get-disaster-icon="getDisasterIcon"
@@ -17,11 +17,11 @@
<InformationBox
:data="waterLoggingPointDetail as Record<string, any>"
:field="field"
v-if="useLoadingInformation.waterLoggingHiddenPoint.loading"
v-if="loadingInformationStore.waterLoggingHiddenPoint.loading"
:title="informationBoxTitle"
:offset-x="offsetX"
:offset-y="offsetY"
:key="useLoadingInformation.waterLoggingHiddenPoint.id"
:key="loadingInformationStore.waterLoggingHiddenPoint.id"
/>
</div>
</template>
@@ -46,9 +46,9 @@
const waterLoggingPoints = ref<Point[]>([]);
const useStatus = useStatusStore();
const useLoadingInformation = useLoadingInformationStore();
const useLoadingResource = useLoadingResourceStore();
const statusStore = useStatusStore();
const loadingInformationStore = useLoadingInformationStore();
const loadingResourceStore = useLoadingResourceStore();
const { field, getDisasterIcon } = useHiddenPoint();
@@ -67,13 +67,13 @@
// 监听id变化
watch(
() => useLoadingInformation.waterLoggingHiddenPoint.id,
() => loadingInformationStore.waterLoggingHiddenPoint.id,
async (newId: number) => {
if (newId === -1) {
return;
}
// 获取内涝隐患点数据
const clickObject = useLoadingInformation.clickObject;
const clickObject = loadingInformationStore.clickObject;
if (!clickObject || !clickObject.primitive) {
console.warn('点击对象或图元不存在');
@@ -81,7 +81,7 @@
}
const res = await $api.hiddenDangerSpots.getPointDetailById(
useLoadingInformation.waterLoggingHiddenPoint.id
loadingInformationStore.waterLoggingHiddenPoint.id
);
// 更新数据
@@ -97,7 +97,7 @@
offsetY.value = screenPos.y;
// 显示新的信息框
useLoadingInformation.waterLoggingHiddenPoint.loading = true;
loadingInformationStore.waterLoggingHiddenPoint.loading = true;
} catch (error) {
throw new Error(`坐标转换失败:${error}`);
}
@@ -106,19 +106,19 @@
// 监听显示隐藏
watch(
() => useStatus.poiLayers.showWaterLoggingHiddenPoint.show,
() => statusStore.poiLayers.showWaterLoggingHiddenPoint.show,
(newValue: boolean) => {
if (newValue) {
// 显示内涝隐患点
CesiumUtilsSingleton.batchShowPrimitives(
useLoadingResource.getLoadingResource(
loadingResourceStore.getLoadingResource(
LoadingResource.WATER_LOGGING_HIDDEN_POINT
).ids
);
} else {
// 隐藏内涝隐患点
CesiumUtilsSingleton.batchHidePrimitives(
useLoadingResource.getLoadingResource(
loadingResourceStore.getLoadingResource(
LoadingResource.WATER_LOGGING_HIDDEN_POINT
).ids
);