From 4e310b1a05f31058ecf12ee7878b5525706c6f15 Mon Sep 17 00:00:00 2001 From: weipengfei <2187978347@qq.com> Date: Fri, 13 Oct 2023 21:37:55 +0800 Subject: [PATCH] s --- src/views/chat/components/Message/index.vue | 26 ++++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/views/chat/components/Message/index.vue b/src/views/chat/components/Message/index.vue index 61663a5..e057c5f 100644 --- a/src/views/chat/components/Message/index.vue +++ b/src/views/chat/components/Message/index.vue @@ -95,25 +95,33 @@ async function handleCopy() { import axios from "axios" -function loadTTS(){ - let tts = props.tts?JSON.parse(props.tts):[] - for(let i=0;i{ + return new Promise((resolve, reject)=>{ axios.post('https://chat.lihaink.cn/index/tts',{data: '你好'}) .then(response => { // 请求成功处理逻辑 console.log('请求成功',response.data); - const a = new Audio(response.data.mp3) + resolve(response.data) + }) + .catch(error => { + // 请求失败处理逻辑 + console.error('请求失败',error); + reject(error) + }); + }) +} + +async function loadTTS(){ + let tts = props.tts?JSON.parse(props.tts):[] + for(let i=0;i { onAudioEnd() }) audioElements.push(a) if (i == 0) playAudio() - }) - .catch(error => { - // 请求失败处理逻辑 - console.error('请求失败',error); - }); } }