From 8170b3f16280e400f0fa981aba20d18856fc94a8 Mon Sep 17 00:00:00 2001 From: wzy-warehouse <18135009705@163.com> Date: Mon, 27 Apr 2026 21:57:12 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=9F=BA=E7=A1=80=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/component/common/LoadingPoints.vue | 13 +++++++------ src/component/map/AdministrativeDivision.vue | 2 +- src/hooks/usePointsHandle.ts | 11 +++++------ src/stores/useLoadingResourceStore.ts | 12 +++++++++--- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/component/common/LoadingPoints.vue b/src/component/common/LoadingPoints.vue index 896eecf..13098a7 100644 --- a/src/component/common/LoadingPoints.vue +++ b/src/component/common/LoadingPoints.vue @@ -24,12 +24,13 @@ onMounted(() => { // 加载点 - const result: { ids: string[]; names: string[] } = pointsHandle.addPoints( - props.basePoints, - props.getDisasterIcon, - props.prefix, - props.isDefault - ); + const result: { ids: string[]; info: Record[] } = + pointsHandle.addPoints( + props.basePoints, + props.getDisasterIcon, + props.prefix, + props.isDefault + ); // 记录id useLoadingResourceStore().addLoadingResource( diff --git a/src/component/map/AdministrativeDivision.vue b/src/component/map/AdministrativeDivision.vue index 8b9e3c4..506d5a8 100644 --- a/src/component/map/AdministrativeDivision.vue +++ b/src/component/map/AdministrativeDivision.vue @@ -47,7 +47,7 @@ // 记录行政区划id useLoadingResourceStore().addLoadingResource( LoadingResource.ADMINISTRATIVE_DIVISION, - { ids: areasId, names: [] } // 此处name不进行记录 + { ids: areasId, info: [] } // 此处info不进行记录 ); }); diff --git a/src/hooks/usePointsHandle.ts b/src/hooks/usePointsHandle.ts index 470bc6f..c0eb936 100644 --- a/src/hooks/usePointsHandle.ts +++ b/src/hooks/usePointsHandle.ts @@ -26,13 +26,13 @@ export const usePointsHandle = () => { getDisasterIcon: (disasterType?: string) => string, prefix: string, isDefault: boolean = false - ): { ids: string[]; names: string[] } { + ): { ids: string[]; info: Record[] } { // 设置加载配置 const options: PrimitiveOptions[] = []; - // 存放id、name + // 存放id、name、经纬度 const ids: string[] = []; - const names: string[] = []; + const info: Record[] = []; points.forEach((point) => { try { @@ -43,9 +43,8 @@ export const usePointsHandle = () => { const position = Cartesian3.fromDegrees(point.lon, point.lat, 10); const id = `${prefix}${point.id}`; - const name = point.name!; ids.push(id); - names.push(name); + info.push({ id, name: point.name!, lon: point.lon, lat: point.lat }); options.push({ id: id, @@ -69,7 +68,7 @@ export const usePointsHandle = () => { // 批量创建图层 CesiumUtilsSingleton.addPrimitivesBatch(options); - return { ids, names }; + return { ids, info }; } return { addPoints }; diff --git a/src/stores/useLoadingResourceStore.ts b/src/stores/useLoadingResourceStore.ts index 0e9c478..fcf8933 100644 --- a/src/stores/useLoadingResourceStore.ts +++ b/src/stores/useLoadingResourceStore.ts @@ -5,13 +5,18 @@ import { ref, type Ref } from 'vue'; // 存储按需加载的数据 export const useLoadingResourceStore = defineStore('loadingResource', () => { const loadingResource: Ref< - Partial> + Partial< + Record< + LoadingResource, + { ids: string[]; info: Record[] } + > + > > = ref({}); // 添加数据 const addLoadingResource = ( key: LoadingResource, - value: { ids: string[]; names: string[] } + value: { ids: string[]; info: Record[] } ) => { loadingResource.value[key] = value; }; @@ -27,10 +32,11 @@ export const useLoadingResourceStore = defineStore('loadingResource', () => { * 获取数据 */ const getLoadingResource = (key: LoadingResource) => { - return loadingResource.value[key] || { ids: [], names: [] }; + return loadingResource.value[key] || { ids: [], info: [] }; }; return { + loadingResource, getLoadingResource, addLoadingResource, removeLoadingResource,