From c347bbea8ba63f2940a97f31a56d9bb60f3ff27e Mon Sep 17 00:00:00 2001 From: wzy-warehouse <18135009705@163.com> Date: Wed, 6 May 2026 17:44:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B7=A6=E4=BE=A7=E5=9B=BE?= =?UTF-8?q?=E4=BE=8B=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rain-earthquake/LeftLegendComponent.vue | 75 +++++++++++++++++++ src/hooks/rain-earthquake/useLayerControl.ts | 46 ++++++++++++ src/hooks/rain-earthquake/useRightHandle.ts | 39 ++++++++++ src/stores/useLeftLegendStore.ts | 16 ++++ src/stores/useStatusStore.ts | 8 ++ src/views/home/rainstorm/RainstormView.vue | 9 +++ 6 files changed, 193 insertions(+) create mode 100644 src/component/rain-earthquake/LeftLegendComponent.vue create mode 100644 src/stores/useLeftLegendStore.ts diff --git a/src/component/rain-earthquake/LeftLegendComponent.vue b/src/component/rain-earthquake/LeftLegendComponent.vue new file mode 100644 index 0000000..331e6a2 --- /dev/null +++ b/src/component/rain-earthquake/LeftLegendComponent.vue @@ -0,0 +1,75 @@ + + + + + {{ useLeftLegendStore().legendListInfo.title }} + + + + + {{ item.label }} + + + + + + + + diff --git a/src/hooks/rain-earthquake/useLayerControl.ts b/src/hooks/rain-earthquake/useLayerControl.ts index 9887f25..ae68a20 100644 --- a/src/hooks/rain-earthquake/useLayerControl.ts +++ b/src/hooks/rain-earthquake/useLayerControl.ts @@ -1,3 +1,4 @@ +import { useLeftLegendStore } from '@/stores/useLeftLegendStore'; import { useStatusStore } from '@/stores/useStatusStore.ts'; /** @@ -58,6 +59,51 @@ export const useLayerControl = () => { const clickPopulationGrid = () => { // 加载状态为true useStatusStore().poiLayers.showPopulationGrid.loading = true; + + if (useStatusStore().poiLayers.showPopulationGrid.show) { + // 显示图例 + useStatusStore().uiComponents.leftLegend.loading = true; + useStatusStore().uiComponents.leftLegend.show = true; + + useLeftLegendStore().legendListInfo.title = '人口密度图例'; + useLeftLegendStore().legendListInfo.list = [ + { + label: 'Min-0 < 100', + color: '#b1fe02', + }, + { + label: '100 ≤ X < 500', + color: '#6bf700', + }, + { + label: '500 ≤ X < 1000', + color: '#fcf600', + }, + { + label: '1000 ≤ X < 2000', + color: '#fecb02', + }, + { + label: '2000 ≤ X < 4000', + color: '#fc9e00', + }, + { + label: '4000 ≤ X < 8000', + color: '#fe7004', + }, + { + label: '8000 ≤ X < 10000', + color: '#fb3f02', + }, + { + label: '10000 ≤ X < Max', + color: '#ff0000', + }, + ]; + } else { + // 隐藏图例 + useStatusStore().uiComponents.leftLegend.show = false; + } }; /** diff --git a/src/hooks/rain-earthquake/useRightHandle.ts b/src/hooks/rain-earthquake/useRightHandle.ts index f4b60f9..bb712ed 100644 --- a/src/hooks/rain-earthquake/useRightHandle.ts +++ b/src/hooks/rain-earthquake/useRightHandle.ts @@ -2,6 +2,7 @@ import { useStatusStore } from '@/stores/useStatusStore.ts'; import { CesiumUtilsSingleton } from '@/utils/cesium/CesiumUtils.ts'; import config from '@/config/config.json'; import { useButtonSelectedIdStore } from '@/stores/useButtonSelectedIdStore'; +import { useLeftLegendStore } from '@/stores/useLeftLegendStore'; export const useRightHandle = () => { /** @@ -13,9 +14,47 @@ export const useRightHandle = () => { // 开启暴雨模拟:显示降雨栅格图层 useStatusStore().weatherLayers.showRainfallGrid.loading = true; useStatusStore().weatherLayers.showRainfallGrid.show = true; + + // 显示图例 + useStatusStore().uiComponents.leftLegend.loading = true; + useStatusStore().uiComponents.leftLegend.show = true; + useLeftLegendStore().legendListInfo.title = '降雨量图例'; + useLeftLegendStore().legendListInfo.list = [ + { + label: '无雨/微雨; <0.1mm/12h', + color: 'rgba(200,200,200,0)', + }, + { + label: '小雨;<5mm/12h', + color: 'rgba(0,0,255,0.4)', + }, + { + label: '中雨; <15mm/12h', + color: 'rgba(0,255,255,0.5)', + }, + { + label: '大雨; <30mm/12h', + color: 'rgba(0,255,0,0.6)', + }, + { + label: '暴雨; <70mm/12h', + color: 'rgba(255,255,0,0.7)', + }, + { + label: '大暴雨; <140mm/12h', + color: 'rgba(255,165,0,0.8)', + }, + { + label: '特大暴雨; >140mm/12h', + color: 'rgba(255,0,0,0.9)', + }, + ]; } else { // 关闭暴雨模拟:隐藏降雨栅格图层 useStatusStore().weatherLayers.showRainfallGrid.show = false; + + // 隐藏图例 + useStatusStore().uiComponents.leftLegend.show = false; } }; diff --git a/src/stores/useLeftLegendStore.ts b/src/stores/useLeftLegendStore.ts new file mode 100644 index 0000000..e32035f --- /dev/null +++ b/src/stores/useLeftLegendStore.ts @@ -0,0 +1,16 @@ +import { defineStore } from 'pinia'; +import { ref, type Ref } from 'vue'; + +/** + * 左侧图例信息 + */ +export const useLeftLegendStore = defineStore('leftLegend', () => { + const legendListInfo: Ref<{ + title: string; + list: { label: string; color: string }[]; + }> = ref({ + title: '', + list: [], + }); + return { legendListInfo }; +}); diff --git a/src/stores/useStatusStore.ts b/src/stores/useStatusStore.ts index 8e4513f..395f226 100644 --- a/src/stores/useStatusStore.ts +++ b/src/stores/useStatusStore.ts @@ -28,6 +28,10 @@ export const useStatusStore = defineStore('status', () => { show: true, loading: true, }, + leftLegend: { + show: false, + loading: false, + }, rightButton: { show: true, loading: true, @@ -210,6 +214,10 @@ export const useStatusStore = defineStore('status', () => { show: true, loading: true, }; + uiComponents.leftLegend = { + show: false, + loading: false, + }; uiComponents.rightButton = { show: true, loading: true, diff --git a/src/views/home/rainstorm/RainstormView.vue b/src/views/home/rainstorm/RainstormView.vue index b043421..f2e3a01 100644 --- a/src/views/home/rainstorm/RainstormView.vue +++ b/src/views/home/rainstorm/RainstormView.vue @@ -29,6 +29,14 @@ :button-list="leftButtonInfo" /> + + +