feat:优化播放状态

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

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

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

Loading…
Cancel
Save