From 5222704c0e73277db1eaf57bce813448a821ffff Mon Sep 17 00:00:00 2001
From: liqi <1174845810@qq.com>
Date: Thu, 3 Apr 2025 22:28:51 +0800
Subject: [PATCH] 1
---
.env.development | 4 +-
src/views/contentData/LeftSidebar/index.vue | 81 ++++-
src/views/menuData/PositionDialog.vue | 309 +-------------------
3 files changed, 73 insertions(+), 321 deletions(-)
diff --git a/.env.development b/.env.development
index 88fb713..11ba95f 100644
--- a/.env.development
+++ b/.env.development
@@ -1,5 +1,3 @@
NODE_ENV = 'development'
-# VUE_APP_API_URL = 'http://192.168.0.74:5002'
-# VUE_APP_API_URL = 'http://111.198.19.33:5002'
-VUE_APP_API_URL = 'http://114.66.57.139:5001/'
+VUE_APP_API_URL = 'http://114.66.57.139:8088'
VUE_APP_MESSAGE_SDK_DEBUG = true
\ No newline at end of file
diff --git a/src/views/contentData/LeftSidebar/index.vue b/src/views/contentData/LeftSidebar/index.vue
index 5bb5598..edb890c 100644
--- a/src/views/contentData/LeftSidebar/index.vue
+++ b/src/views/contentData/LeftSidebar/index.vue
@@ -38,14 +38,20 @@
-
+ style="display: none"
+ >
+
+
+
@@ -97,6 +103,7 @@ export default {
iswarning: false
};
},
+ mounted() {},
watch: {
homeData: {
handler(newVal) {
@@ -142,14 +149,31 @@ export default {
mapUavFiex(this.drones);
}
let alarm = this.drones.find((d) => d.alarmLevel === 1);
+ const media = this.$refs.uavAudio; // 修正 ref 名称为 "uavAudio"
if (alarm) {
this.iswarning = true;
- const media = this.$refs.nativeElement;
- media.muted = true;
- media.play();
+ this.$nextTick(() => {
+ if (media) {
+ media.muted = true; // 初始静音
+ media
+ .play()
+ .then(() => {
+ console.log("播放成功,取消静音");
+ media.muted = false; // 播放成功后取消静音
+ })
+ .catch((error) => {
+ console.log("播放失败:", error);
+ this.showAudioPrompt = true; // 播放失败时显示提示框
+ });
+ }
+ });
} else {
- console.log(222);
+ console.log("无告警");
this.iswarning = false;
+ if (media) {
+ media.pause(); // 无告警时停止播放
+ media.currentTime = 0; // 重置到开始
+ }
}
}
},
@@ -157,6 +181,26 @@ export default {
}
},
methods: {
+ enableAudio() {
+ this.iswarning = true;
+ const media = this.$refs.uavAudio;
+ let time = setInterval(() => {
+ console.log("用户手动启用音频", media);
+ if (media !== undefined) {
+ clearInterval(time);
+ media.muted = false; // 取消静音
+ media
+ .play()
+ .then(() => {
+ console.log("用户手动启用音频成功");
+ this.showAudioPrompt = false; // 关闭提示框
+ })
+ .catch((error) => {
+ console.error("手动播放失败:", error);
+ });
+ }
+ }, 500);
+ },
startTimer(item) {
return setInterval(() => {
if (item.currTime > 0) {
@@ -260,4 +304,19 @@ export default {
.left-sidebar.contracted {
transform: translateX(-90%);
}
+.audio-prompt {
+ position: fixed;
+ top: 0;
+ left: 50%;
+ width: 15%;
+ height: 10%;
+ background: rgba(0, 0, 0, 0.5);
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ z-index: 1000;
+ color: #fff;
+ border-radius: 5px;
+ transform: translateX(-50%);
+}
diff --git a/src/views/menuData/PositionDialog.vue b/src/views/menuData/PositionDialog.vue
index b34ee84..7c34d2d 100644
--- a/src/views/menuData/PositionDialog.vue
+++ b/src/views/menuData/PositionDialog.vue
@@ -44,11 +44,6 @@
alt=""
/>
-
-
- {{ data.onlineStatus == 0 ? "正常" : "离线" }}
-
-