From 9f55452e21a84c5c46528a0de51ccd7796643470 Mon Sep 17 00:00:00 2001
From: chenyao <1219716595@qq.com>
Date: Thu, 03 Apr 2025 08:23:33 +0800
Subject: [PATCH] Merge branch 'master' of http://139.196.74.78:10010/r/drone/command-center-dashboard
---
Dockerfile.test | 4
/dev/null | 213 ------------------------------------------
src/views/Home/useMapAggregation/DevicePopUpBox.vue | 0
src/views/Home/useMapAggregation/EventPopUpBox.vue | 0
package.json | 3
.env | 7 +
.env.production | 12 --
src/views/Home/useMapAggregation/useMapAggregation.js | 36 +++---
.env.test | 4
src/views/Home/Footer.vue | 7
10 files changed, 36 insertions(+), 250 deletions(-)
diff --git a/.env b/.env
new file mode 100644
index 0000000..2cadb46
--- /dev/null
+++ b/.env
@@ -0,0 +1,7 @@
+VITE_APP_API = /api
+#调试参数
+VITE_APP_DEBUG_KEY = saber
+VITE_APP_DEBUG_SWITCH = false
+
+#页面基础路径
+VITE_APP_BASE = /command-center-dashboard/
diff --git a/.env.production b/.env.production
index 25204d2..f641060 100644
--- a/.env.production
+++ b/.env.production
@@ -1,17 +1,5 @@
#生产环境配置
VITE_APP_ENV = 'production'
-#接口地址
-#填写前缀 [/api] 需要用nginx进行反向代理
-#填写地址 [https://api.bladex.cn] 只需要保证接口支持跨域即可, 无需再做代理
-VITE_APP_API=/api
-
-#调试参数
-VITE_APP_DEBUG_KEY=saber
-VITE_APP_DEBUG_SWITCH=false
-
-#页面基础路径
-VITE_APP_BASE = /command-center-dashboard/
-
# 是否在打包时开启压缩,支持 gzip 和 brotli
VITE_BUILD_COMPRESS = gzip
diff --git a/.env.test b/.env.test
new file mode 100644
index 0000000..04a567e
--- /dev/null
+++ b/.env.test
@@ -0,0 +1,4 @@
+
+#测试环境配置
+VITE_APP_ENV = 'test'
+
diff --git a/Dockerfile.test b/Dockerfile.test
index 70bfabd..b463a31 100644
--- a/Dockerfile.test
+++ b/Dockerfile.test
@@ -10,7 +10,7 @@
RUN rm -rf node_modules package-lock.json && npm install --registry=https://registry.npmmirror.com
# 构建项目
-RUN npm run build:dev
+RUN npm run build:test
# 查看
-RUN ls /app/dist
\ No newline at end of file
+RUN ls /app/dist
diff --git a/package.json b/package.json
index de29db4..51ddf33 100644
--- a/package.json
+++ b/package.json
@@ -5,6 +5,7 @@
"dev": "vite --host",
"prod": "vite --mode production",
"build:dev": "vite build --mode development",
+ "build:test": "vite build --mode test",
"build:prod": "vite build --mode production",
"serve": "vite preview --host",
"format": "prettier --write \"src/**/*.+(js|ts|jsx|tsx)\""
@@ -52,4 +53,4 @@
"vite-plugin-svg-icons": "^2.0.1",
"vite-plugin-vue-setup-extend": "^0.4.0"
}
-}
\ No newline at end of file
+}
diff --git a/src/views/Home/Footer.vue b/src/views/Home/Footer.vue
index fbe52c5..5962dba 100644
--- a/src/views/Home/Footer.vue
+++ b/src/views/Home/Footer.vue
@@ -25,13 +25,12 @@
import img5 from '@/assets/images/home/footer/orthophoto.png'
import activeImg5 from '@/assets/images/home/footer/orthophoto1.png'
-import { useUavHome } from '@/views/Home/useUavHome/useUavHome'
-import { useEventOperate } from '@/views/Home/useEventOperate/useEventOperate'
+import { useMapAggregation } from '@/views/Home/useMapAggregation/useMapAggregation'
// 机巢聚合
-const { init, removeAll } = useUavHome('device');
+const { init, removeAll } = useMapAggregation('device');
// 事件聚合
-const { init: eventInit, removeAll: eventRemove } = useUavHome('event');
+const { init: eventInit, removeAll: eventRemove } = useMapAggregation('event');
const list = ref([
{
diff --git a/src/views/Home/useEventOperate/useEventOperate.js b/src/views/Home/useEventOperate/useEventOperate.js
deleted file mode 100644
index 205b988..0000000
--- a/src/views/Home/useEventOperate/useEventOperate.js
+++ /dev/null
@@ -1,213 +0,0 @@
-import * as Cesium from 'cesium';
-import data2 from '@/assets/images/home/homeRight/data2.png';
-import eventImg from '@/assets/images/home/useEventOperate/event.png';
-import jiangxishi from '@/assets/geojson/jiangxishi.json';
-import jiangxi from '@/assets/geojson/jiangxi.json';
-import zg from '@/assets/geojson/zg.json';
-import EventPopUpBox from './EventPopUpBox.vue';
-import { render } from 'vue';
-import store from '@/store';
-
-/**
- * 事件聚合功能
- */
-export const useEventOperate = () => {
- const scalingJudgment = [
- { name: '县', value: [0, 48651], gJson: null },
- { name: '市', value: [48651, 314863], gJson: jiangxishi },
- { name: '省', value: [314863, 1169651], gJson: jiangxi },
- { name: '国', value: [1169651, 37962800], gJson: zg },
- ]
- let viewer = null
- let active = null
- let handler = null
- let positionC3 = null
- const listenerHeight = () => {
- determineScaling()
- viewer.camera.moveEnd.addEventListener(determineScaling)
- }
-
- // 确定缩放比例
- const determineScaling = () => {
- if (!viewer) return
- let height = viewer.camera.positionCartographic.height
- // 根据高度展示对应的 gJson
- for (let item of scalingJudgment) {
- if (height > item.value[0] && height <= item.value[1]) {
- if (active !== item.name) {
- removeEntities()
- removeLabel()
- active = item.name
- item.gJson ? aggregation(item) : splashed()
- }
- break
- }
- }
- }
-
- //散点机巢
- function splashed() {
- for (let i = 0; i < 50; i++) {
- viewer.entities.add({
- position: Cesium.Cartesian3.fromDegrees(
- 115.89 + Math.random() * 0.2,
- 28.68 + Math.random() * 0.2
- ),
- label: {
- // 随机整数
- text: Math.floor(Math.random() * 100) + '号事件',
- font: '14pt monospace',
- fillColor: Cesium.Color.WHITE,
- outlineColor: Cesium.Color.BLACK,
- outlineWidth: 2,
- style: Cesium.LabelStyle.FILL_AND_OUTLINE,
- verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
- pixelOffset: new Cesium.Cartesian2(0, -9),
- },
- billboard: {
- image: new Cesium.ConstantProperty(eventImg),
- width: 24,
- height: 24,
- },
- })
- }
- }
-
- // 聚合机巢
- const aggregation = item => {
- const featuresList = item.gJson.features.map(item => ({
- name: item.properties.name,
- position: item.properties.center,
- }))
- // 遍历特征并添加实体
- featuresList.forEach(feature => {
- if (!feature.position) return
- const position = Cesium.Cartesian3.fromDegrees(feature.position[0], feature.position[1])
- viewer.entities.add({
- id: feature.id,
- position: position,
- label: {
- // 随机整数
- text: Math.floor(Math.random() * 100) + '个事件',
- font: '14pt monospace',
- fillColor: Cesium.Color.WHITE,
- outlineColor: Cesium.Color.BLACK,
- outlineWidth: 2,
- style: Cesium.LabelStyle.FILL_AND_OUTLINE,
- verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
- pixelOffset: new Cesium.Cartesian2(0, -9),
- },
- billboard: {
- image: new Cesium.ConstantProperty(data2),
- width: 24,
- height: 24,
- },
- properties: {
- id: feature.id,
- customData: {
- name: feature.name,
- },
- },
- })
- })
- // 加载新的 GeoJSON 数据
- Cesium.GeoJsonDataSource.load(item.gJson).then(dataSource => {
- viewer.dataSources.add(dataSource)
- item.dataSource = dataSource // 保存数据源以便后续删除
- // 获取数据源中的实体
- const entities = dataSource.entities.values
- entities.forEach(entity => {
- entity.polygon.material = new Cesium.ColorMaterialProperty(
- Cesium.Color.YELLOW.withAlpha(0) // 透明填充
- )
- entity.polygon.outline = new Cesium.ConstantProperty(true) // 显示边框
- entity.polygon.outlineColor = new Cesium.ConstantProperty(Cesium.Color.YELLOW) // 黑色边框
- })
- })
- }
-
- // 获取弹框box
- const getLabelDom = () => {
- const vNode = h(EventPopUpBox, { data: '参数', removeLabel })
- const tooltipContainer = document.createElement('div')
- tooltipContainer.id = 'mapPopUpBox'
- tooltipContainer.style.position = 'absolute'
- tooltipContainer.style.transform = 'translate(-50%,-110%)'
- tooltipContainer.style.pointerEvents = 'none'
- document.querySelector('.page-index').append(tooltipContainer)
- render(vNode, tooltipContainer)
- return tooltipContainer
- }
-
- // 弹框位置刷新
- const labelBox = () => {
- store.commit('setSingleUavHome', {
- id: '123',
- })
- let dom = document.querySelector('#mapPopUpBox')
- if (!dom) {
- dom = getLabelDom()
- }
- const screenPosition = viewer.scene.cartesianToCanvasCoordinates(positionC3)
- if (screenPosition) {
- dom.style.left = `${screenPosition.x}px`
- dom.style.top = `${screenPosition.y}px`
- dom.style.display = 'block'
- }
- }
-
- // 左键单机事件
- const singleMachineEvent = click => {
- const pickedObject = viewer.scene.pick(click.position)
- if (Cesium.defined(pickedObject) && pickedObject.id) {
- const entity = pickedObject.id
- positionC3 = entity?.position?._value
- if (!positionC3) return
- viewer.scene.postRender.removeEventListener(labelBox)
- viewer.scene.postRender.addEventListener(labelBox)
- }
- }
-
- // 移除 点 和 gjson 实体
- const removeEntities = () => {
- viewer.dataSources?.removeAll(true)
- viewer.entities?.removeAll()
- }
- // 移除弹框标签
- const removeLabel = () => {
- viewer.scene.postRender.removeEventListener(labelBox)
- const dom = document.querySelector('#mapPopUpBox')
- if (dom && dom.parentNode) {
- dom.parentNode.removeChild(dom)
- }
- }
-
- // 移除所有监听事件,变量置空
- const removeAll = () => {
- removeEntities()
- removeLabel()
- viewer.camera.moveEnd.removeEventListener(determineScaling)
- handler?.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK)
- handler?.destroy()
- viewer = null
- active = null
- handler = null
- positionC3 = null
- }
- const init = () => {
- viewer = window.$viewer
- handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas)
- handler.setInputAction(singleMachineEvent, Cesium.ScreenSpaceEventType.LEFT_CLICK)
- listenerHeight()
- }
- // onMounted(() => {
- // nextTick(() => {
- // viewer = window.$viewer;
- // handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
- // handler.setInputAction(singleMachineEvent, Cesium.ScreenSpaceEventType.LEFT_CLICK);
- // listenerHeight();
- // });
- // });
-
- return { init, removeAll }
-}
diff --git a/src/views/Home/useUavHome/DevicePopUpBox.vue b/src/views/Home/useMapAggregation/DevicePopUpBox.vue
similarity index 100%
rename from src/views/Home/useUavHome/DevicePopUpBox.vue
rename to src/views/Home/useMapAggregation/DevicePopUpBox.vue
diff --git a/src/views/Home/useEventOperate/EventPopUpBox.vue b/src/views/Home/useMapAggregation/EventPopUpBox.vue
similarity index 100%
rename from src/views/Home/useEventOperate/EventPopUpBox.vue
rename to src/views/Home/useMapAggregation/EventPopUpBox.vue
diff --git a/src/views/Home/useUavHome/useUavHome.js b/src/views/Home/useMapAggregation/useMapAggregation.js
similarity index 95%
rename from src/views/Home/useUavHome/useUavHome.js
rename to src/views/Home/useMapAggregation/useMapAggregation.js
index 3c8b93c..1617249 100644
--- a/src/views/Home/useUavHome/useUavHome.js
+++ b/src/views/Home/useMapAggregation/useMapAggregation.js
@@ -4,8 +4,8 @@
import eventImg from '@/assets/images/home/useEventOperate/event.png';
-import DevicePopUpBox from '@/views/Home/useUavHome/DevicePopUpBox.vue';
-import EventPopUpBox from '@/views/Home/useEventOperate/EventPopUpBox.vue';
+import DevicePopUpBox from '@/views/Home/useMapAggregation/DevicePopUpBox.vue';
+import EventPopUpBox from '@/views/Home/useMapAggregation/EventPopUpBox.vue';
import { render } from 'vue';
import { useStore } from 'vuex';
@@ -16,7 +16,7 @@
/**
* 机巢聚合功能
*/
-export const useUavHome = type => {
+export const useMapAggregation = type => {
const { flyTo } = cesiumOperation();
const singleImg = type === 'device' ? uavImg : eventImg;
@@ -117,22 +117,22 @@
function getMapEventCount(areaCode) {
return getMapEvents({ areaCode }).then(res => {
- return processChildren(res?.data?.data?.childrens || []);
- });
- }
- function getEventDetailsFun(areaCode){
- return getEventDetails({areaCode}).then(res => {
- console.log(res.data.data,'getEventDetailsFun');
+ const resData= res?.data?.data
+ if (resData?.data){
+ eventList = resData?.data
+ return []
+ }
+ return processChildren(resData?.childrens);
});
}
const findFun = (featItem, numItem) => Number(featItem.region_code.slice(0, 6)) === numItem.properties.adcode;
- const { VITE_APP_BASE } = import.meta.env;
- const defaultDir = `${VITE_APP_BASE}public/geoJson/100000/`;
+ const { VITE_APP_BASE,VITE_APP_ENV } = import.meta.env;
+ const defaultDir = `${VITE_APP_BASE}${VITE_APP_ENV === 'development' ? 'public/' : ''}geoJson/100000/`;
const getFiler = async url => {
- const gJson = await import(/* @vite-ignore */ url);
- return JSON.parse(JSON.stringify(gJson));
+ const res = await fetch(url);
+ return await res.json()
};
const getOutLine = async (jsonPathPre, hierarchy) => {
const parentGJson = await getFiler(`${defaultDir}${jsonPathPre}/index.json`);
@@ -150,6 +150,7 @@
};
const initMapData = async areaCode => {
+ eventList = []
if (!areaCode) return;
const list = type === 'device' ? await getDeviceCount(areaCode) : await getMapEventCount(areaCode);
const splashedList = type === 'device'
@@ -164,8 +165,9 @@
scalingJudgment[0].gJson = null;
scalingJudgment[0].splashedList = splashedList;
active = null;
- console.log(hierarchy);
-
+ // 轮廓
+ const outlineGJson = await getOutLine(jsonPathPre, hierarchy);
+ scalingJudgment.forEach(item => item.show && (item.outline = outlineGJson));
// 省
if (hierarchy.length === 1) {
const gJson1 = await getFiler(`${defaultDir}${jsonPath}/indexDistrict.json`);
@@ -200,9 +202,7 @@
const center = outlineGJson.features[0].properties.center;
flyTo({ longitude: center[0], latitude: center[1] }, 0, scalingJudgment[0].height);
}
- // 轮廓
- const outlineGJson = await getOutLine(jsonPathPre, hierarchy);
- scalingJudgment.forEach(item => item.show && (item.outline = outlineGJson));
+ determineScaling()
};
watch(
--
Gitblit v1.9.3