From 785b59c2adbd6fce015dce5cbfb2476bb12c56d3 Mon Sep 17 00:00:00 2001 From: lifizer <913626195@qq.com> Date: Mon, 29 Jun 2026 16:59:00 +0800 Subject: [PATCH] =?UTF-8?q?Fix(=E4=BA=91=E7=81=B5AI):[#5394]=E5=9C=A8?= =?UTF-8?q?=E4=BA=91=E7=81=B5ai=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E7=AA=97=E5=8F=A3=EF=BC=8C=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E3=80=90=E8=AF=AD=E9=9F=B3=E6=92=AD=E6=94=BE=E3=80=91=EF=BC=8C?= =?UTF-8?q?=E6=92=AD=E6=94=BE=E4=B8=AD=E6=97=B6=E7=82=B9=E5=87=BB=E9=87=8D?= =?UTF-8?q?=E6=96=B0=E7=94=9F=E6=88=90=EF=BC=8C=E8=AF=AD=E9=9F=B3=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E8=BF=98=E5=9C=A8=E7=BB=A7=E7=BB=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- aiChat/mixins/chatMixins.js | 13 ++++++++----- aiChat/mixins/chatMixinsV2.js | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/aiChat/mixins/chatMixins.js b/aiChat/mixins/chatMixins.js index 75a53c2..5b59f6b 100644 --- a/aiChat/mixins/chatMixins.js +++ b/aiChat/mixins/chatMixins.js @@ -100,10 +100,7 @@ export const chatMixins = { }.bind(this)).exec() }, onUnload() { - if (this.audioContext) { - this.audioContext.stop() - } - wx.getBackgroundAudioManager().stop() + this.audioStopHandle() this.closeWsFn() }, created() { @@ -447,9 +444,15 @@ export const chatMixins = { this.audioAyy = [] if (this.audioContext) { this.audioContext.stop() + this.audioContext.destroy() // 强制销毁释放资源 + this.audioContext = null } this.isPlayAudio = false - wx.getBackgroundAudioManager().stop() + + // 强制关闭微信小程序背景音频 + if (typeof wx !== 'undefined' && wx.getBackgroundAudioManager) { + wx.getBackgroundAudioManager().stop() + } }, ttsHandle(item) { this.audioAyy = [] diff --git a/aiChat/mixins/chatMixinsV2.js b/aiChat/mixins/chatMixinsV2.js index 8431818..78dd5ff 100644 --- a/aiChat/mixins/chatMixinsV2.js +++ b/aiChat/mixins/chatMixinsV2.js @@ -81,10 +81,7 @@ export const chatMixinsV2 = { }.bind(this)).exec() }, onUnload() { - if (this.audioContext) { - this.audioContext.stop() - } - wx.getBackgroundAudioManager().stop() + this.audioStopHandle() this.closeWsFn() }, created() { @@ -670,9 +667,15 @@ export const chatMixinsV2 = { this.audioAyy = [] if (this.audioContext) { this.audioContext.stop() + this.audioContext.destroy() // 强制销毁释放资源 + this.audioContext = null } this.isPlayAudio = false - wx.getBackgroundAudioManager().stop() + + // 强制关闭微信小程序背景音频 + if (typeof wx !== 'undefined' && wx.getBackgroundAudioManager) { + wx.getBackgroundAudioManager().stop() + } }, ttsHandle(item) { this.audioAyy = []