首次提交
This commit is contained in:
@@ -15,18 +15,28 @@
|
||||
<div class="urgent-title mb-6">
|
||||
{{ currentNotification?.content?.message || "无内容" }}
|
||||
</div>
|
||||
<div class="urgent-subtitle mb-6">
|
||||
<div class="urgent-subtitle mb-6">
|
||||
{{ senderName }} {{ deviceType }} {{ formatTime(currentNotification?.timestamp) }}
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- 多通知导航 -->
|
||||
<div v-if="hasMultipleNotifications" class="navigation-controls mt-6">
|
||||
<v-card variant="flat" color="rgba(255,255,255,0.1)">
|
||||
<div
|
||||
v-if="hasMultipleNotifications"
|
||||
class="navigation-controls mt-6"
|
||||
>
|
||||
<v-card
|
||||
variant="flat"
|
||||
color="rgba(255,255,255,0.1)"
|
||||
>
|
||||
<v-card-text class="text-center">
|
||||
<div class="notification-counter mb-3">
|
||||
<v-chip color="white" variant="flat" size="small">
|
||||
<v-chip
|
||||
color="white"
|
||||
variant="flat"
|
||||
size="small"
|
||||
>
|
||||
{{ notificationCountText }}
|
||||
</v-chip>
|
||||
</div>
|
||||
@@ -59,8 +69,15 @@
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<div class="mt-8">
|
||||
<v-btn color="white" size="large" variant="flat" @click="close">
|
||||
<v-icon left> mdi-check </v-icon>
|
||||
<v-btn
|
||||
color="white"
|
||||
size="large"
|
||||
variant="flat"
|
||||
@click="close"
|
||||
>
|
||||
<v-icon left>
|
||||
mdi-check
|
||||
</v-icon>
|
||||
我知道了
|
||||
</v-btn>
|
||||
</div>
|
||||
@@ -75,7 +92,7 @@
|
||||
<script>
|
||||
import EventSender from "@/components/EventSender.vue";
|
||||
import { getSetting } from "@/utils/settings.js";
|
||||
import { playSound, stopSound } from "@/utils/soundList.js";
|
||||
import { playSoundAsync, stopSound } from "@/utils/soundList.js";
|
||||
|
||||
export default {
|
||||
name: "UrgentNotification",
|
||||
@@ -297,7 +314,7 @@ export default {
|
||||
};
|
||||
return labels[deviceType] || deviceType;
|
||||
},
|
||||
playNotificationSound() {
|
||||
async playNotificationSound() {
|
||||
try {
|
||||
// 停止之前的音频
|
||||
this.stopNotificationSound();
|
||||
@@ -307,15 +324,10 @@ export default {
|
||||
? getSetting('notification.urgentSound')
|
||||
: getSetting('notification.singleSound');
|
||||
|
||||
// 使用配置的铃声文件
|
||||
this.currentAudio = playSound(soundFile, false);
|
||||
|
||||
if (!this.currentAudio) {
|
||||
// 如果播放失败,使用备用蜂鸣音
|
||||
this.playFallbackSound();
|
||||
}
|
||||
this.currentAudio = await playSoundAsync(soundFile, false);
|
||||
} catch (error) {
|
||||
console.warn("无法播放通知音效:", error);
|
||||
this.currentAudio = null;
|
||||
this.playFallbackSound();
|
||||
}
|
||||
},
|
||||
@@ -405,7 +417,7 @@ export default {
|
||||
}
|
||||
},
|
||||
// 启动加急通知的定时音效
|
||||
startUrgentSound() {
|
||||
async startUrgentSound() {
|
||||
this.stopUrgentSound(); // 先清除之前的定时器
|
||||
|
||||
// 停止之前的音频
|
||||
@@ -413,10 +425,10 @@ export default {
|
||||
|
||||
// 播放循环铃声
|
||||
const soundFile = getSetting('notification.urgentSound');
|
||||
this.currentAudio = playSound(soundFile, true); // 循环播放
|
||||
|
||||
if (!this.currentAudio) {
|
||||
// 如果播放失败,使用备用方案:每秒播放一次提示音
|
||||
try {
|
||||
this.currentAudio = await playSoundAsync(soundFile, true);
|
||||
} catch {
|
||||
this.currentAudio = null;
|
||||
this.urgentSoundTimer = setInterval(() => {
|
||||
if (this.visible && this.isUrgent) {
|
||||
this.playFallbackSound();
|
||||
|
||||
Reference in New Issue
Block a user