feat:优化播放状态

main
@0Melon0 12 months ago
parent 81d7140c35
commit 66524cf5df

@ -7,7 +7,7 @@ const routes = [
{
path: '/',
name: 'home',
redirect: '/waitList',
redirect: '/monitor',
},
{
path: '/pageBox',

@ -100,6 +100,7 @@ export default {
popupMsgList: [],
showPopup: false,
hasPlay: false,
playNum: 0,
popupMag: [],
popupTimer: null,
synth: window.speechSynthesis,
@ -184,6 +185,8 @@ export default {
if (frame.body) {
let data = JSON.parse(frame.body);
this.popupMsgList.push(data['msg'].replaceAll('', ','));
this.popupMsgList.push(data['msg'].replaceAll('', ','));
this.popupMsgList.push(data['msg'].replaceAll('', ','));
}
} catch (e) {
console.log(e);
@ -202,6 +205,7 @@ export default {
this.hasPlay = true;
this.popupMag = this.popupMsgList[0].replace(/[,]/g, '').split('#');
this.showPopup = true;
this.playNum++;
if (this.synth) {
const utterance = new SpeechSynthesisUtterance([this.popupMsgList[0]].join(''));
utterance.rate = 0.4;
@ -215,10 +219,15 @@ export default {
// onend
utterance.onend = function () {
this.popupMag = [];
this.showPopup = false;
this.hasPlay = false;
this.popupMsgList.shift();
setTimeout(() => {
if (this.playNum >= 3) {
this.popupMag = [];
this.showPopup = false;
this.playNum = 0;
}
this.hasPlay = false;
this.popupMsgList.shift();
}, 1000);
}.bind(this);
this.synth.speak(utterance);
@ -256,6 +265,8 @@ export default {
// setTimeout(() => {
// this.popupMsgList.push(',,#,');
// this.popupMsgList.push(',,#,');
// this.popupMsgList.push(',,#,');
// }, 3000);
});
},

Loading…
Cancel
Save