修复智控台音频播放权限bug

This commit is contained in:
hrz
2025-05-04 20:03:13 +08:00
parent a144570ed7
commit 81359bf419
5 changed files with 67 additions and 29 deletions
+15 -15
View File
@@ -128,19 +128,19 @@ export default {
});
}).send();
},
}
export function getAgentSessions(agentId, params) {
return request({
url: `/agent/${agentId}/sessions`,
method: 'get',
params
});
}
export function getAgentChatHistory(agentId, sessionId) {
return request({
url: `/agent/${agentId}/chat-history/${sessionId}`,
method: 'get'
});
// 获取音频下载ID
getAudioId(audioId, callback) {
RequestService.sendRequest()
.url(`${getServiceUrl()}/agent/audio/${audioId}`)
.method('POST')
.success((res) => {
RequestService.clearRequestTime();
callback(res);
})
.fail(() => {
RequestService.reAjaxFun(() => {
this.getAudioId(audioId, callback);
});
}).send();
},
}
@@ -66,7 +66,7 @@ export default {
currentSessionId: '',
currentMacAddress: '',
page: 1,
limit: 10,
limit: 20,
loading: false,
hasMore: true,
scrollTimer: null,
@@ -237,16 +237,21 @@ export default {
this.audioElement = null;
}
// 播放新音频
// 先获取音频下载ID
this.playingAudioId = message.audioId;
this.audioElement = new Audio(Api.getServiceUrl() + `/agent/audio/${message.audioId}`);
Api.agent.getAudioId(message.audioId, (res) => {
if (res.data && res.data.data) {
// 使用获取到的下载ID播放音频
this.audioElement = new Audio(Api.getServiceUrl() + `/agent/play/${res.data.data}`);
this.audioElement.onended = () => {
this.playingAudioId = null;
this.audioElement = null;
};
this.audioElement.onended = () => {
this.playingAudioId = null;
this.audioElement = null;
};
this.audioElement.play();
this.audioElement.play();
}
});
},
getUserAvatar(sessionId) {
// 从 sessionId 中提取所有数字
@@ -269,7 +274,7 @@ export default {
<style scoped>
.chat-container {
display: flex;
height: 600px;
height: 100%;
}
.session-list {
@@ -422,7 +427,7 @@ export default {
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
height: 80vh;
height: 90vh;
max-width: 85vw;
border-radius: 12px;
overflow: hidden;
@@ -436,7 +441,7 @@ export default {
.chat-history-dialog .el-dialog__body {
padding: 0;
overflow: hidden;
height: calc(80vh - 54px);
height: calc(90vh - 54px);
/* 减去标题栏的高度 */
}
</style>