|
@ -35,15 +35,16 @@ export default { |
|
|
showNotify(para){ |
|
|
showNotify(para){ |
|
|
let _this = this; |
|
|
let _this = this; |
|
|
let eventType = ["trafficAccident", "vehicleBroken", "trafficControl", "trafficJam", "illegalVehicle", "barrierClear", "construction", "serviceAreaAbnormal", "equipmentTrouble", "abnormalWeather", "otherEvent"]; |
|
|
let eventType = ["trafficAccident", "vehicleBroken", "trafficControl", "trafficJam", "illegalVehicle", "barrierClear", "construction", "serviceAreaAbnormal", "equipmentTrouble", "abnormalWeather", "otherEvent"]; |
|
|
|
|
|
let time = para.subEvent == "0" ? para.content.event.occurrenceTime : para.content.event.warning_time; |
|
|
let obj = { |
|
|
let obj = { |
|
|
content: para.content.content, |
|
|
content: para.content.content, |
|
|
time: para.subEvent == "0" ? para.content.event.occurrenceTime : para.content.event.warning_time, |
|
|
time, |
|
|
// moment().format("yyyy-MM-DD hh:mm"), |
|
|
// moment().format("yyyy-MM-DD hh:mm"), |
|
|
type: para.subEvent == '1' ? "signal" : eventType[para.content.event.eventType*1-1], |
|
|
type: para.subEvent == '1' ? "signal" : eventType[para.content.event.eventType*1-1], |
|
|
level: ["danger", "info"][para.subEvent*1], |
|
|
level: ["danger", "info"][para.subEvent*1], |
|
|
duration: para.subEvent == "0" ? 0 : 4000 |
|
|
duration: para.subEvent == "0" ? 0 : 4000 |
|
|
} |
|
|
} |
|
|
|
|
|
this.speak(time + '' + para.content.content); |
|
|
_this.notifications[_this.notifyIndex] = _this.$notify({ |
|
|
_this.notifications[_this.notifyIndex] = _this.$notify({ |
|
|
title: '', |
|
|
title: '', |
|
|
dangerouslyUseHTMLString: true, |
|
|
dangerouslyUseHTMLString: true, |
|
@ -124,6 +125,25 @@ export default { |
|
|
), |
|
|
), |
|
|
}); |
|
|
}); |
|
|
_this.notifyIndex++; |
|
|
_this.notifyIndex++; |
|
|
|
|
|
}, |
|
|
|
|
|
speak(text){ |
|
|
|
|
|
// 创建SpeechSynthesisUtterance实例 |
|
|
|
|
|
const utterance = new SpeechSynthesisUtterance(text); |
|
|
|
|
|
|
|
|
|
|
|
// 设置语音的语言 |
|
|
|
|
|
utterance.lang = 'zh-CN'; // 中文简体 |
|
|
|
|
|
|
|
|
|
|
|
// 设置语音的音量(0到1之间) |
|
|
|
|
|
utterance.volume = 10; |
|
|
|
|
|
|
|
|
|
|
|
// 设置语音的语速(1是正常语速) |
|
|
|
|
|
utterance.rate = 1; |
|
|
|
|
|
|
|
|
|
|
|
// 设置语音的音调(可以是"default", "female", "male") |
|
|
|
|
|
utterance.pitch = 1; |
|
|
|
|
|
|
|
|
|
|
|
// 使用SpeechSynthesis接口播放语音 |
|
|
|
|
|
window.speechSynthesis.speak(utterance); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
mounted() { |
|
|
mounted() { |
|
|