mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-25 08:33:53 +08:00
Merge branch 'main' into py-display
This commit is contained in:
@@ -73,6 +73,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { debounce } from '@/utils'
|
||||
import Api from '@/apis/api';
|
||||
|
||||
export default {
|
||||
@@ -115,6 +116,10 @@ export default {
|
||||
if (val) {
|
||||
this.resetData();
|
||||
this.loadSessions();
|
||||
} else {
|
||||
this.audioElement?.pause();
|
||||
this.audioElement = null;
|
||||
this.playingAudioId = null;
|
||||
}
|
||||
},
|
||||
dialogVisible(val) {
|
||||
@@ -305,7 +310,7 @@ export default {
|
||||
}
|
||||
return 'el-icon-video-play';
|
||||
},
|
||||
playAudio(message) {
|
||||
playAudio: debounce(function(message) {
|
||||
if (this.playingAudioId === message.audioId) {
|
||||
// 如果正在播放当前音频,则停止播放
|
||||
if (this.audioElement) {
|
||||
@@ -326,9 +331,12 @@ export default {
|
||||
this.playingAudioId = message.audioId;
|
||||
Api.agent.getAudioId(message.audioId, (res) => {
|
||||
if (res.data && res.data.data) {
|
||||
if (!this.audioElement) {
|
||||
this.audioElement = new Audio();
|
||||
}
|
||||
|
||||
// 使用获取到的下载ID播放音频
|
||||
this.audioElement = new Audio(Api.getServiceUrl() + `/agent/play/${res.data.data}`);
|
||||
|
||||
this.audioElement.src = Api.getServiceUrl() + `/agent/play/${res.data.data}`;
|
||||
this.audioElement.onended = () => {
|
||||
this.playingAudioId = null;
|
||||
this.audioElement = null;
|
||||
@@ -337,7 +345,7 @@ export default {
|
||||
this.audioElement.play();
|
||||
}
|
||||
});
|
||||
},
|
||||
}, 300),
|
||||
getUserAvatar(sessionId) {
|
||||
// 从 sessionId 中提取所有数字
|
||||
const numbers = sessionId.match(/\d+/g);
|
||||
|
||||
Reference in New Issue
Block a user