增加声音提醒
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
public
|
||||
src/assets
|
||||
node_modules
|
||||
dist
|
||||
@@ -1,23 +0,0 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
env: {
|
||||
browser: true,
|
||||
node: true,
|
||||
es6: true
|
||||
},
|
||||
parser: 'vue-eslint-parser',
|
||||
extends: [
|
||||
'plugin:vue/essential',
|
||||
'eslint:recommended',
|
||||
'plugin:prettier/recommended'
|
||||
],
|
||||
parserOptions: {
|
||||
ecmaVersion: 2020,
|
||||
sourceType: 'module'
|
||||
},
|
||||
rules: {
|
||||
'no-console': 'off',
|
||||
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
|
||||
'vue/multi-word-component-names': 'off'
|
||||
}
|
||||
};
|
||||
Binary file not shown.
@@ -110,6 +110,9 @@
|
||||
</el-tab-pane>
|
||||
-->
|
||||
</el-tabs>
|
||||
<audio ref="notificationSound" preload="auto">
|
||||
<source src="@/assets/audio/message-ding.mp3" type="audio/mpeg">
|
||||
</audio>
|
||||
</el-popover>
|
||||
</template>
|
||||
|
||||
@@ -145,23 +148,21 @@
|
||||
window.EventBus.$on('ws:message', (message) => {
|
||||
console.log('收到 WebSocket 消息:', message);
|
||||
if (message.type === 'notice') {
|
||||
this.notice = [message.data].concat(this.notice);
|
||||
this.noticeCount++;
|
||||
//弹窗通知有新消息
|
||||
this.$notify({
|
||||
title: '', // 消息标题
|
||||
message: '您收到一条新的系统通知,请及时查看', // 消息内容
|
||||
title: '消息提醒', // 消息标题
|
||||
message: message.data.content ? message.data.content: '您收到一条新的系统通知,请及时查看', // 消息内容
|
||||
type: 'warning', // 类型:info/success/warning/error
|
||||
duration: 5000, // 5秒后自动关闭,0则不自动关闭
|
||||
position: 'top-left', // 弹窗位置,可选top-left/bottom-left/bottom-right
|
||||
showClose: true, // 显示关闭按钮
|
||||
onClick: () => {}
|
||||
});
|
||||
//怎么在最开头拼接
|
||||
this.notice = [message.data].concat(this.notice);
|
||||
this.noticeCount++;
|
||||
// this.notice = message.data;
|
||||
//提醒声音
|
||||
this.playNotificationSound();
|
||||
}
|
||||
// 处理具体的业务逻辑
|
||||
// this.handleWebSocketMessage(message);
|
||||
});
|
||||
|
||||
// 监听 WebSocket 错误
|
||||
@@ -174,6 +175,14 @@
|
||||
this.query();
|
||||
},
|
||||
methods: {
|
||||
// 播放提示音
|
||||
playNotificationSound() {
|
||||
const audio = this.$refs.notificationSound;
|
||||
audio.currentTime = 0; // 重置播放位置(支持连续多次播放)
|
||||
audio.play().catch((err) => {
|
||||
console.log("提示音播放失败(浏览器限制):", err);
|
||||
});
|
||||
},
|
||||
/* 查询数据 */
|
||||
query() {
|
||||
// getUnreadNotice()
|
||||
|
||||
Reference in New Issue
Block a user