问题更改

This commit is contained in:
zengmingjie 2025-06-25 22:27:05 +08:00
parent ff01490947
commit 5c9ab6cc4c
5 changed files with 218 additions and 128 deletions

View File

@ -1,3 +1,3 @@
NODE_ENV = 'development' NODE_ENV = 'development'
VUE_APP_API_URL = 'http://114.66.57.139:8092' VUE_APP_API_URL = 'http://114.66.57.139:8090'
VUE_APP_MESSAGE_SDK_DEBUG = true VUE_APP_MESSAGE_SDK_DEBUG = true

View File

@ -1,5 +1,6 @@
<template> <template>
<div class="left-sidebar" :class="{ contracted: isContracted }"> <div class="left-sidebar" :class="{ contracted: isContracted }">
<div class="alarm-border warningAnimatBox" v-if="iswarning"></div>
<div class="stats"> <div class="stats">
<div class="stat-item" v-for="(item, index) in warningDay" :key="index"> <div class="stat-item" v-for="(item, index) in warningDay" :key="index">
<div class="stat-name">{{ item.name }}</div> <div class="stat-name">{{ item.name }}</div>
@ -125,7 +126,7 @@
type="primary" type="primary"
@click.stop="handlewhiteList(drone)" @click.stop="handlewhiteList(drone)"
> >
信任 {{ drone.IsWhitelist ? "信任" : "取消信任" }}
</el-button> </el-button>
</div> </div>
<div class="btn-navigation"> <div class="btn-navigation">
@ -210,7 +211,7 @@ import { mapUavFiex } from "../index.js";
import Style from "ol/style/Style"; import Style from "ol/style/Style";
import Stroke from "ol/style/Stroke"; import Stroke from "ol/style/Stroke";
import { fromLonLat, toLonLat } from "ol/proj"; import { fromLonLat, toLonLat } from "ol/proj";
import { whitListAdd } from "@/api/whitList.js"; import { whitListAdd, whitListDelete } from "@/api/whitList.js";
import QRCode from "qrcode"; import QRCode from "qrcode";
export default { export default {
@ -252,7 +253,8 @@ export default {
showAudioPrompt: false, showAudioPrompt: false,
startTime: "", // startTime: "", //
endTime: "", endTime: "",
qrCodeUrl: "" qrCodeUrl: "",
isAudioPlaying: false //
}; };
}, },
computed: { computed: {
@ -290,7 +292,6 @@ export default {
signaData: { signaData: {
handler(newVal) { handler(newVal) {
if (newVal) { if (newVal) {
console.log(newVal, "newVal");
// newVal = [ // newVal = [
// { // {
// BatchId: "1936279216064696320", // BatchId: "1936279216064696320",
@ -370,42 +371,67 @@ export default {
if (this.drones) { if (this.drones) {
mapUavFiex(this.drones, window.olMap); mapUavFiex(this.drones, window.olMap);
} }
let alarm = this.drones.find((d) => d.alarmLevel === 0);
const media = this.$refs.uavAudio; const media = this.$refs.uavAudio;
const savedVolume = localStorage.getItem("soundValue"); let alarm = this.drones.find((d) => d.alarmLevel === 1);
if (alarm) { if (alarm) {
this.iswarning = true; this.iswarning = true;
this.$nextTick(() => { this.$nextTick(() => {
if (media) { if (media) {
media.muted = true; // media.muted = true; //
const savedVolume = localStorage.getItem("soundValue");
media.volume = savedVolume !== null ? savedVolume / 100 : 1;
media.muted = this.isZoomedIn ? false : true;
//
if (!this.isAudioPlaying) {
media media
.play() .play()
.then(() => { .then(() => {
console.log("播放成功,取消静音"); console.log("播放音频");
if (savedVolume !== null) { this.isAudioPlaying = true;
media.volume = savedVolume / 100; //
media.onended = () => {
if (this.iswarning) {
media.play().catch((error) => {
console.log("循环播放失败:", error);
this.showAudioPrompt = true;
});
} else { } else {
media.volume = 1; this.isAudioPlaying = false;
}
if (this.isZoomedIn) {
media.muted = false; //
} else {
media.muted = true; //
} }
};
}) })
.catch((error) => { .catch((error) => {
console.log("播放失败:", error); console.log("播放失败:", error);
this.showAudioPrompt = true; // this.showAudioPrompt = true;
this.isAudioPlaying = false;
}); });
} }
}
}); });
} else { } else if (!alarm && this.iswarning) {
//
this.iswarning = false; this.iswarning = false;
if (media) { if (media) {
media.pause(); // media.pause();
media.currentTime = 0; // media.currentTime = 0;
this.isAudioPlaying = false;
media.onended = null; //
this.showAudioPrompt = false;
} }
} }
//
if (newVal.length === 0) {
this.iswarning = false;
this.showAudioPrompt = false;
this.isAudioPlaying = false;
if (media) {
media.pause();
media.currentTime = 0;
media.onended = null;
}
vectorSource.clear();
}
} }
}, },
deep: true deep: true
@ -441,16 +467,16 @@ export default {
"&dname=飞手位置&dev=0&t=0"; "&dname=飞手位置&dev=0&t=0";
// App // App
setTimeout(() => { // setTimeout(() => {
const isAppOpened = document.hidden || document.webkitHidden; // const isAppOpened = document.hidden || document.webkitHidden;
if (!isAppOpened) { // if (!isAppOpened) {
this.$message.warning("未安装高德地图 App将打开网页版导航"); // this.$message.warning(" App");
window.open( // window.open(
`https://uri.amap.com/navigation?to=${drone.app_lon},${drone.app_lat},飞手位置&callnative=1`, // `https://uri.amap.com/navigation?to=${drone.app_lon},${drone.app_lat},&callnative=1`,
"_blank" // "_blank"
); // );
} // }
}, 1000); // }, 1000);
}, },
noNavigation(drone) { noNavigation(drone) {
this.$set(this.navigationStates, drone.BatchId, false); this.$set(this.navigationStates, drone.BatchId, false);
@ -493,15 +519,33 @@ export default {
company: " ", company: " ",
mark: " " mark: " "
}; };
if (drone.IsWhitelist) {
whitListAdd(params) whitListAdd(params)
.then((res) => { .then((res) => {
if (res.code === 0) { if (res.code === 0) {
console.log(res, "添加成功"); console.log(res, "添加成功");
this.$message.success("添加成功");
} else {
this.$message.error(res.msg);
} }
}) })
.catch((err) => { .catch((err) => {
console.log(err, "添加失败"); this.$message.error(err);
}); });
} else {
whitListDelete({ id: drone.Id })
.then((res) => {
if (res.code === 0) {
this.$message.success("移除成功");
} else {
this.$message.error(res.msg);
}
})
.catch((err) => {
this.$message.error(err);
console.log(err, "移除失败");
});
}
}, },
enableAudio() { enableAudio() {
this.iswarning = true; this.iswarning = true;
@ -697,7 +741,7 @@ export default {
if (drone.drone_lon !== 0 && drone.drone_lat !== 0) { if (drone.drone_lon !== 0 && drone.drone_lat !== 0) {
window.olMap.getView().animate({ window.olMap.getView().animate({
center: fromLonLat([drone.drone_lon, drone.drone_lat]), center: fromLonLat([drone.drone_lon, drone.drone_lat]),
zoom: 13 zoom: window.olMap.getView().getZoom()
}); });
} }
}, },
@ -726,21 +770,26 @@ export default {
position: absolute; position: absolute;
bottom: -100%; bottom: -100%;
} }
.audio-prompt { .alarm-border {
position: fixed; position: fixed;
top: 0%; top: 0;
left: 50%; left: 0;
bottom: -100%; right: 0;
width: 20%; bottom: 0;
height: 10%; border: 1px solid transparent;
background: rgba(0, 0, 0, 0.5); pointer-events: none; /* Prevent interaction with the border */
display: flex; z-index: 9999; /* Ensure it appears above other elements */
justify-content: center; &.warningAnimatBox {
align-items: center; animation: greenanimated-shadow 2s infinite;
z-index: 1000; }
color: #fff; }
border-radius: 5px; @keyframes greenanimated-shadow {
transform: translateX(-50%); 0% {
pointer-events: auto; box-shadow: 0 0 0 0 #e1f850 inset;
}
85% {
box-shadow: 0px 0px 100px 0px #e1f850 inset;
}
} }
</style> </style>

View File

@ -73,6 +73,7 @@ export default {
watch: { watch: {
positionPoint: { positionPoint: {
handler(newVal) { handler(newVal) {
if (newVal) {
// this.$message.success(this.latitude + ", " + this.longitude); // this.$message.success(this.latitude + ", " + this.longitude);
console.log("位置更新", newVal, this.latitude, this.longitude); console.log("位置更新", newVal, this.latitude, this.longitude);
if (newVal && this.latitude && this.longitude && window.olMap) { if (newVal && this.latitude && this.longitude && window.olMap) {
@ -87,8 +88,13 @@ export default {
center: newLocation, center: newLocation,
zoom: zoomLevel zoom: zoomLevel
}); });
} else {
this.$message.error("定位失败,请稍后重试");
}
if (this.latitude === "" || this.longitude === "") {
} }
this.$store.commit("SET_POSITIONPOINT", false); this.$store.commit("SET_POSITIONPOINT", false);
}
}, },
deep: true deep: true
} }

View File

@ -439,7 +439,6 @@ export function mapUavFiex(options, map) {
graphicLayerGJ.getSource().addFeature(track); graphicLayerGJ.getSource().addFeature(track);
graphicLayerGJ.setStyle(null); graphicLayerGJ.setStyle(null);
} }
console.log(graphicLayer, graphicLayerGJ, graphic, "graphic");
// 更新无人机属性和位置 // 更新无人机属性和位置
graphic.set("attr", item); graphic.set("attr", item);

View File

@ -3,6 +3,7 @@
<div class="zoom-level" @click="soundAndMenu"> <div class="zoom-level" @click="soundAndMenu">
<img :src="zoomLevelImage" alt="" /> <img :src="zoomLevelImage" alt="" />
</div> </div>
<div class="zoom-control">刻度尺{{ zoomControl }}</div>
<div class="btn-container" v-if="closeBtnVisible"> <div class="btn-container" v-if="closeBtnVisible">
<el-button @click="handleClickClose()">返回</el-button> <el-button @click="handleClickClose()">返回</el-button>
</div> </div>
@ -66,6 +67,7 @@ import { Vector as VectorLayer } from "ol/layer";
import { Vector as VectorSource } from "ol/source"; import { Vector as VectorSource } from "ol/source";
import { Style, Fill, Stroke, Circle } from "ol/style"; import { Style, Fill, Stroke, Circle } from "ol/style";
import GeoJSON from "ol/format/GeoJSON"; import GeoJSON from "ol/format/GeoJSON";
import LayerGroup from "ol/layer/Group";
import AlertDialog from "../menuData/AlertDialog.vue"; import AlertDialog from "../menuData/AlertDialog.vue";
import { devPositionList } from "@/api/position.js"; import { devPositionList } from "@/api/position.js";
@ -85,7 +87,9 @@ export default {
value2: 0, value2: 0,
currentBaseMap: "gaode", currentBaseMap: "gaode",
dialogQueryVisible: false, dialogQueryVisible: false,
closeBtnVisible: false closeBtnVisible: false,
zoomControl: 0,
toggleMap: false
}; };
}, },
created() { created() {
@ -227,14 +231,13 @@ export default {
}, },
modelClick() { modelClick() {
// //
const newBaseMap = this.currentBaseMap === "gaode" ? "tianditu" : "gaode"; window.olMap.getLayers().forEach((layer) => {
this.map.getLayers().forEach((layer) => { if (layer.get("title") === "白色底图组") {
const name = layer.get("name"); layer.setVisible(this.toggleMap);
if (name === "gaode" || name === "tianditu") { } else if (layer.get("title") === "暗色底图组") {
layer.setVisible(name === newBaseMap); layer.setVisible(!this.toggleMap);
} }
}); });
this.currentBaseMap = newBaseMap;
}, },
soundAndMenu() { soundAndMenu() {
this.isZoomedIn = !this.isZoomedIn; this.isZoomedIn = !this.isZoomedIn;
@ -243,56 +246,42 @@ export default {
initMap() { initMap() {
// OpenLayers // OpenLayers
this.map = new Map({ this.map = new Map({
target: this.$refs.olMap, target: "map", // this.$refs.olMap Vue
layers: [ layers: [
new TileLayer({ // +
name: "gaode", // new LayerGroup({
visible: true, title: "白色底图组",
source: new XYZ({ layers: [
visible: true, this.createTiandituLayer("vec", "天地图矢量底图"), //
url: "http://webrd01.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=2&scale=1&style=8" this.createTiandituLayer("cia", "天地图默认注记") //
}) ],
visible: true //
}), }),
new TileLayer({ // +
name: "tianditu", // new LayerGroup({
visible: false, title: "暗色底图组",
source: new XYZ({ layers: [
url: "http://webrd01.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scale=1&style=7", this.createTiandituLayer(
layer: "img", "vec",
style: "default", "天地图暗色底图",
matrixSet: "c", "grayscale(98%) invert(100%) sepia(20%) hue-rotate(180deg) saturate(1600%) brightness(80%) contrast(90%)"
format: "tiles", ), //
tileLoadFunction: function (imageTile, src) { this.createTiandituLayer(
// 使 "cia",
const img = new Image(); "天地图白色注记",
// img.crossOrigin = '' "grayscale(100%) brightness(150%) contrast(120%)"
// ) //
img.setAttribute("crossOrigin", "anonymous"); ],
img.onload = function () { visible: false //
const canvas = document.createElement("canvas");
const w = img.width;
const h = img.height;
canvas.width = w;
canvas.height = h;
const context = canvas.getContext("2d");
context.filter =
"grayscale(98%) invert(100%) sepia(20%) hue-rotate(180deg) saturate(1600%) brightness(80%) contrast(90%)";
context.drawImage(img, 0, 0, w, h, 0, 0, w, h);
imageTile.getImage().src = canvas.toDataURL("image/png");
};
img.src = src;
}
}),
format: new GeoJSON()
}) })
], ],
view: new View({ view: new View({
projection: "EPSG:3857", projection: "EPSG:3857",
center: fromLonLat([117.337103, 39.040924]), // center: fromLonLat([117.337103, 39.040924]), //
zoom: 10, zoom: 10,
minZoom: 3, minZoom: 0,
maxZoom: 18, maxZoom: 18,
constrainRotation: false // constrainRotation: false
}) })
}); });
@ -317,6 +306,35 @@ export default {
// //
this.zoomLevel = Math.round(this.map.getView().getZoom()); this.zoomLevel = Math.round(this.map.getView().getZoom());
}, },
createTiandituLayer(layerType, title, filter = null) {
let tiandituKey = "a78289a00ac2e57e0e7abe1d8560d644";
return new TileLayer({
visible: true,
name: title,
source: new XYZ({
url: `http://t{0-7}.tianditu.gov.cn/${layerType}_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=${layerType}&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=${tiandituKey}`,
tileLoadFunction: filter
? (imageTile, src) => {
const img = new Image();
img.setAttribute("crossOrigin", "anonymous");
img.onload = function () {
const canvas = document.createElement("canvas");
const w = img.width;
const h = img.height;
canvas.width = w;
canvas.height = h;
const context = canvas.getContext("2d");
context.filter = filter;
context.drawImage(img, 0, 0, w, h, 0, 0, w, h);
imageTile.getImage().src = canvas.toDataURL("image/png");
};
img.src = src;
}
: undefined
}),
title: title
});
},
onMapLoad(map) { onMapLoad(map) {
setTimeout(() => { setTimeout(() => {
this.initPositon(); this.initPositon();
@ -333,6 +351,13 @@ export default {
map.getView().setMinZoom(3); // map.getView().setMinZoom(3); //
map.getView().setMaxZoom(18); // map.getView().setMaxZoom(18); //
} }
//
const view = map.getView();
this.zoomControl = view.getZoom();
view.on("change:resolution", () => {
this.zoomControl = Math.round(view.getZoom());
console.log(this.zoomControl, "缩放级别已更改");
});
}, },
handleClose() { handleClose() {
this.dialogVisible = false; this.dialogVisible = false;
@ -437,6 +462,17 @@ export default {
height: 48px; height: 48px;
} }
} }
.zoom-control {
position: absolute;
left: 60px;
bottom: 30px;
z-index: 1000;
color: #fff;
img {
width: 48px;
height: 48px;
}
}
.btn-container { .btn-container {
position: absolute; position: absolute;
top: 70px; top: 70px;