From 946d4921c79a081ee07defb5d8a807c01a2241c7 Mon Sep 17 00:00:00 2001
From: zhangchen <1652267879@qq.com>
Date: 星期五, 20 六月 2025 14:00:10 +0800
Subject: [PATCH] ID1743-允许通过ip访问

---
 src/views/deviceWindoes2.vue |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/src/views/deviceWindoes2.vue b/src/views/deviceWindoes2.vue
index 0ea9ec0..189bb11 100644
--- a/src/views/deviceWindoes2.vue
+++ b/src/views/deviceWindoes2.vue
@@ -1532,6 +1532,7 @@
         <div class="dialog-footer">
           <el-button @click="centerDialogVisible = false">取消</el-button>
           <el-button @click="test">测试播报</el-button>
+          <el-button @click="toggleAlarm">测试报警</el-button>
           <el-button type="primary" @click="saveSet"> 确认 </el-button>
           <el-button type="success" @click="shuaxin"> 刷新 </el-button>
         </div>
@@ -1664,6 +1665,8 @@
 import cljd from "../img/cljd.png";
 import tizhong from "../img/tizhong.png";
 import { EventSourcePolyfill } from "event-source-polyfill";
+import alertbaojin from '../assets/alert.wav'
+
 import {
   computed,
   getCurrentInstance,
@@ -1678,6 +1681,23 @@
 import * as echarts from "echarts";
 import { jgTime4 } from "../utils/formatTime";
 import { setTimeoutAlert } from "../utils/httpApi";
+// 创建 Audio 对象,指向 public 目录下的音频文件
+const alarmSound = new Audio(alertbaojin)
+
+// 控制播放状态的变量
+const isPlaying = ref(false)
+// 切换播放/暂停的方法
+const toggleAlarm = () => {
+  if (isPlaying.value) {
+    alarmSound.pause()
+  } else {
+    alarmSound.currentTime = 0 // 从头开始播放
+    alarmSound.play().catch((err) => {
+      console.error('播放失败:', err)
+    })
+  }
+  isPlaying.value = !isPlaying.value
+}
 // 语音播报
 import Speech from "speak-tts";
 const speech = ref(null);
@@ -2125,7 +2145,8 @@
     if(centerDialogVisible3.value===false){
       centerDialogVisible3.value = true;
       关闭弹框警告();
-      播报警告文本(倒计时告警文本.value);
+      // 播报警告文本(倒计时告警文本.value);
+      toggleAlarm()
     }
   
   }else{
@@ -2270,6 +2291,7 @@
               倒计时告警文本.value = dataBody.倒计时?.提醒文本;
               关闭弹框警告();
               播报警告文本(倒计时告警文本.value);
+              toggleAlarm()
             } else if (倒计时.value <= -60) {
               centerDialogVisible3.value = false;
             }
@@ -2334,6 +2356,7 @@
   setTimeout(function () {
     console.log("30秒已过,关闭报警设置弹框。");
     centerDialogVisible3.value = false;
+    toggleAlarm()
     倒计时.value=-100
   }, 30000); // 30000 毫秒 = 30 秒
 };

--
Gitblit v1.8.0