From 674d10b063ac39eadcb409457958d850320924fc Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期一, 23 六月 2025 14:51:47 +0800
Subject: [PATCH] 添加样式表引入
---
src/views/deviceWindoes2.vue | 62 +++++++++++++++++++++++++++++-
1 files changed, 59 insertions(+), 3 deletions(-)
diff --git a/src/views/deviceWindoes2.vue b/src/views/deviceWindoes2.vue
index d789940..189bb11 100644
--- a/src/views/deviceWindoes2.vue
+++ b/src/views/deviceWindoes2.vue
@@ -1531,6 +1531,8 @@
<template #footer>
<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>
@@ -1663,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,
@@ -1677,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);
@@ -1949,6 +1970,7 @@
if (res.data === "OK") {
倒计时.value = minutes * 60;
centerDialogVisible2.value = false;
+ 倒计时告警文本.value = alertText
} else {
ElMessage.warning(res.message);
}
@@ -2109,7 +2131,7 @@
return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}`;
};
-const 倒计时 = ref(0);
+const 倒计时 = ref(-100);
const 倒计时显示 = ref("00:00:00");
const 倒计时告警文本 = ref("");
// 定时器回调函数
@@ -2117,7 +2139,17 @@
if (倒计时.value > 0) {
倒计时显示.value = formatSecondsToTime(倒计时.value);
倒计时.value--;
- } else {
+ } else if(倒计时.value!==-100) {
+ 倒计时显示.value = "";
+ // 只有没触发的时候才触发他
+ if(centerDialogVisible3.value===false){
+ centerDialogVisible3.value = true;
+ 关闭弹框警告();
+ // 播报警告文本(倒计时告警文本.value);
+ toggleAlarm()
+ }
+
+ }else{
倒计时显示.value = "";
}
};
@@ -2254,11 +2286,12 @@
if (dataBody.倒计时?.提醒文本) {
倒计时.value = dataBody.倒计时?.设定提醒倒计时;
console.log("设置了倒计时值", 倒计时.value);
- if (倒计时.value <= 0 && 倒计时.value >= -60) {
+ if (倒计时.value <= 0 && 倒计时.value >= -60&& centerDialogVisible3.value===false) {
centerDialogVisible3.value = true;
倒计时告警文本.value = dataBody.倒计时?.提醒文本;
关闭弹框警告();
播报警告文本(倒计时告警文本.value);
+ toggleAlarm()
} else if (倒计时.value <= -60) {
centerDialogVisible3.value = false;
}
@@ -2323,10 +2356,13 @@
setTimeout(function () {
console.log("30秒已过,关闭报警设置弹框。");
centerDialogVisible3.value = false;
+ toggleAlarm()
+ 倒计时.value=-100
}, 30000); // 30000 毫秒 = 30 秒
};
const 播报警告文本 = (tex) => {
if (centerDialogVisible3.value) {
+ console.log(centerDialogVisible3.value,'播报')
speech.value
.speak({
text: tex,
@@ -2350,6 +2386,26 @@
});
}
};
+const test=()=>{
+ speech.value
+ .speak({
+ text: '你好,我现在在测试播报内容',
+ listeners: {
+ //开始播放
+ onstart: () => {
+ console.log("开始播报");
+ },
+ //判断播放是否完毕
+ onend: () => {
+ console.log("播报完成");
+ },
+ //恢复播放
+ onresume: () => {
+ console.log("Resume utterance");
+ },
+ },
+ })
+}
//初始化
const sourceInit = () => {
console.log("初始化see");
--
Gitblit v1.8.0