From 43eda7e0ebca2130d5714dcf4005530a2824b3f1 Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期四, 19 六月 2025 10:31:36 +0800
Subject: [PATCH] gx报警测试
---
src/views/deviceWindoes2.vue | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/src/views/deviceWindoes2.vue b/src/views/deviceWindoes2.vue
index 0ea9ec0..eb75eea 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="playAlarm">测试报警</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,16 @@
import * as echarts from "echarts";
import { jgTime4 } from "../utils/formatTime";
import { setTimeoutAlert } from "../utils/httpApi";
+// 创建 Audio 对象,指向 public 目录下的音频文件
+const alarmSound = new Audio(alertbaojin)
+
+// 播放报警声的方法
+const playAlarm = () => {
+ alarmSound.currentTime = 0 // 重置到开头,以便可以重复播放
+ alarmSound.play().catch((err) => {
+ console.error('播放失败:', err)
+ })
+}
// 语音播报
import Speech from "speak-tts";
const speech = ref(null);
--
Gitblit v1.8.0