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