mirror of
https://github.com/kuaifan/dootask.git
synced 2026-01-13 01:28:11 +00:00
perf: 撤回语音消息时停止正在播放
This commit is contained in:
parent
939da1278f
commit
06951bbc29
@ -27,6 +27,7 @@ export default {
|
||||
return {
|
||||
audioSubscribe: null,
|
||||
audioPlay: false,
|
||||
audioId: 0,
|
||||
audioSrc: null,
|
||||
callback: null,
|
||||
}
|
||||
@ -48,19 +49,22 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
setAudioPlay(info) {
|
||||
setAudioPlay(msg) {
|
||||
const audio = this.$refs.audio;
|
||||
const ended = audio.ended || audio.paused;
|
||||
audio.controls = false;
|
||||
audio.loop = false;
|
||||
audio.volume = 1;
|
||||
if (info === false) {
|
||||
if (!ended) {
|
||||
if (/\d+/.test(msg)) {
|
||||
msg = msg == this.audioId
|
||||
}
|
||||
if (typeof msg === "boolean") {
|
||||
if (!msg && !ended) {
|
||||
audio.pause()
|
||||
}
|
||||
return
|
||||
}
|
||||
const {src, callback} = info
|
||||
const {id, src, callback} = msg
|
||||
this.callback = callback || null;
|
||||
if (src === this.audioSrc) {
|
||||
if (ended) {
|
||||
@ -69,6 +73,7 @@ export default {
|
||||
audio.pause();
|
||||
}
|
||||
} else {
|
||||
this.audioId = id;
|
||||
this.audioSrc = src;
|
||||
if (!ended) {
|
||||
audio.pause()
|
||||
|
||||
@ -132,9 +132,7 @@ export default {
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
if (this.recordPlay) {
|
||||
Store.set('audioSubscribe', false);
|
||||
}
|
||||
Store.set('audioSubscribe', this.msgData.id);
|
||||
},
|
||||
|
||||
computed: {
|
||||
@ -304,6 +302,7 @@ export default {
|
||||
|
||||
playRecord() {
|
||||
Store.set('audioSubscribe', {
|
||||
id: this.msgData.id,
|
||||
src: this.msgData.msg.path,
|
||||
callback: (play) => {
|
||||
this.recordPlay = play;
|
||||
|
||||
1
resources/assets/js/store/actions.js
vendored
1
resources/assets/js/store/actions.js
vendored
@ -2097,6 +2097,7 @@ export default {
|
||||
ids.some(id => {
|
||||
let index = state.dialogMsgs.findIndex(item => item.id == id);
|
||||
if (index > -1) {
|
||||
Store.set('audioSubscribe', id);
|
||||
state.dialogMsgs.splice(index, 1);
|
||||
}
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user