diff --git a/src/api/AIxiaocaishen.js b/src/api/AIxiaocaishen.js index 0cbce31..2b6ee70 100644 --- a/src/api/AIxiaocaishen.js +++ b/src/api/AIxiaocaishen.js @@ -99,12 +99,13 @@ export const getAnnouncementAPI = function () { // 获取用户次数接口 export const getUserCountAPI = function (params) { return request({ - url: `${APIurl}/api/ai_god/userUsageInfo`, + // 'http://39.101.133.168:8828/link/api/aiEmotion/client/getRemainNum', + url: `${APIurl}/api/aiEmotion/client/getRemainNum`, method: "POST", - data: new URLSearchParams(params), - headers: { - "Content-Type": "application/x-www-form-urlencoded", - }, + data: params, + // headers: { + // "Content-Type": "application/x-www-form-urlencoded", + // }, }); }; // 推荐问题/每日复盘/小财神简介点击事件接口 diff --git a/src/store/chat.js b/src/store/chat.js index 6da35cb..dbf5685 100644 --- a/src/store/chat.js +++ b/src/store/chat.js @@ -11,9 +11,10 @@ export const useChatStore = defineStore('chat', { actions: { async getUserCount() { const result = await getUserCountAPI({ - token: localStorage.getItem('localToken') + token: localStorage.getItem('localToken'), + source: '1' }) - this.UserCount = result.data.hasCount + this.UserCount = result.data }, setLoading(status) { this.isLoading = status diff --git a/src/views/AIchat.vue b/src/views/AIchat.vue index c67dfe4..0aedc18 100644 --- a/src/views/AIchat.vue +++ b/src/views/AIchat.vue @@ -144,6 +144,69 @@ const pauseAudio = () => { } }; +// 音频轮流播放方法 +const playAudioSequence = (audioUrls) => { + if (!audioUrls || audioUrls.length === 0) { + console.warn("音频URL列表为空,跳过播放"); + return; + } + + let currentIndex = 0; + + const playNext = () => { + if (currentIndex >= audioUrls.length) { + console.log("所有音频播放完成"); + return; + } + + const currentUrl = audioUrls[currentIndex]; + console.log(`正在播放第${currentIndex + 1}个音频:`, currentUrl); + + // 停止当前播放的音频 + if (audioStore.nowSound) { + audioStore.nowSound.stop(); + } + + const sound = new Howl({ + src: [currentUrl], + html5: true, + format: ["mp3", "acc"], + rate: 1.2, + onplay: () => { + audioStore.isPlaying = true; + console.log(`开始播放音频 ${currentIndex + 1}`); + }, + onend: () => { + audioStore.isPlaying = false; + console.log(`音频 ${currentIndex + 1} 播放完成`); + currentIndex++; + // 播放下一个音频 + setTimeout(() => { + playNext(); + }, 500); // 间隔500ms播放下一个 + }, + onstop: () => { + audioStore.isPlaying = false; + }, + onloaderror: (id, err) => { + console.error(`音频 ${currentIndex + 1} 加载失败:`, err); + currentIndex++; + // 跳过失败的音频,播放下一个 + setTimeout(() => { + playNext(); + }, 100); + } + }); + + audioStore.nowSound = sound; + audioStore.setAudioInstance(sound); + sound.play(); + }; + + // 开始播放第一个音频 + playNext(); +}; + // 获取消息 const chatMsg = computed(() => chatStore.messages); const props = defineProps({ @@ -492,6 +555,18 @@ watch( const result23 = await dbqbSecondThreeAPI(params2); const result24 = await dbqbSecondFourAPI(params2); + // 收集所有音频URL + const audioUrls = []; + if (result21.data.url) audioUrls.push(result21.data.url.trim()); + if (result22.data.url) audioUrls.push(result22.data.url.trim()); + if (result23.data.url) audioUrls.push(result23.data.url.trim()); + if (result24.data.url) audioUrls.push(result24.data.url.trim()); + + // 开始轮流播放音频 + if (audioUrls.length > 0 && audioStore.isVoiceEnabled) { + playAudioSequence(audioUrls); + } + const katexRegex = /\$\$(.*?)\$\$/g; // 删除正在为您生成信息 chatStore.messages.pop(); diff --git a/src/views/AiEmotion.vue b/src/views/AiEmotion.vue index 5555617..1664660 100644 --- a/src/views/AiEmotion.vue +++ b/src/views/AiEmotion.vue @@ -801,7 +801,7 @@ async function handleSendMessage(input) { aibullPrivilegeState: "1", aigoldBullPrivilegeS: "1", airadarPrivilegeStat: "1", - marketList: "hk,cn,usa,my,sg,vi,in,gb", + marketList: "hk,cn,can,usa,my,sg,vi,in,gb", }, };