Browse Source

温度计y轴刻度值修改,最小值向下取整,最大值向上取整;独立两个模型的音频仓库文件;

hongxilin/hotfix-20250625101643-手机输入法弹出输入框上浮
宋杰 1 week ago
parent
commit
2883c89b3e
  1. 89
      src/store/emotionAudio.js
  2. 40
      src/views/AiEmotion.vue
  3. 8
      src/views/components/marketTemperature.vue
  4. 20
      src/views/homePage.vue

89
src/store/emotionAudio.js

@ -0,0 +1,89 @@
import { defineStore } from 'pinia'
export const useEmotionAudioStore = defineStore('emotionAudio', {
state: () => ({
soundInstance: null, // Howl 实例
isPlaying: false, // 播放状态
isVoiceEnabled: true, // 新增声音开关状态
playbackPosition: 0, // 新增播放位置存储
lastVoiceState: null,
ttsUrl:'',
isNewInstance: false, // 新增是否是新实例的标志
nowSound:'',
currentAudioUrl: '', // 当前音频URL
isPaused: false, // 是否处于暂停状态
duration: 0 // 音频总时长
}),
actions: {
// 设置音频实例
setAudioInstance(instance) {
this.soundInstance = instance
},
// 播放控制
play() {
if (this.soundInstance) {
if (this.isPaused && this.playbackPosition > 0) {
// 从暂停位置继续播放
this.soundInstance.seek(this.playbackPosition)
}
this.soundInstance.play()
this.isPlaying = true
this.isPaused = false
}
},
// 暂停控制
pause() {
if (this.soundInstance && this.isPlaying) {
// 保存当前播放位置
this.playbackPosition = this.soundInstance.seek() || 0
this.soundInstance.pause()
this.isPlaying = false
this.isPaused = true
}
},
// 停止播放
stop() {
if (this.soundInstance) {
this.soundInstance.stop()
this.isPlaying = false
this.isPaused = false
this.playbackPosition = 0
}
},
// 切换播放/暂停
togglePlayPause() {
if (this.isPlaying) {
this.pause()
} else {
this.play()
}
},
// 设置当前音频URL
setCurrentAudioUrl(url) {
if (this.currentAudioUrl !== url) {
// 如果是新的音频,重置播放状态
this.stop()
this.currentAudioUrl = url
this.playbackPosition = 0
this.isPaused = false
}
},
// 语音开关控制
toggleVoice() {
this.isVoiceEnabled = !this.isVoiceEnabled
if (!this.isVoiceEnabled) {
// 关闭语音时停止当前播放
this.stop()
}
},
// 重置音频状态
resetAudioState() {
this.stop()
this.currentAudioUrl = ''
this.ttsUrl = ''
this.soundInstance = null
this.nowSound = ''
}
}
})

40
src/views/AiEmotion.vue

@ -182,14 +182,14 @@ import StockTabs from '@/views/components/StockTabs.vue'; // 导入股票标签
import blueBorderImg from '@/assets/img/AiEmotion/blueBorder.png' //
import { ElMessage } from 'element-plus';
import { useEmotionStore } from '@/store/emotion'; // Pinia store
import { useAudioStore } from '@/store/audio.js'; // store
import { useEmotionAudioStore } from '@/store/emotionAudio.js'; // store
import { useChatStore } from '@/store/chat.js'; // store
import { Howl, Howler } from 'howler'; //
import { reactive } from 'vue';
import { marked } from 'marked'; // marked
// 使Pinia store
const emotionStore = useEmotionStore();
const audioStore = useAudioStore();
const emotionAudioStore = useEmotionAudioStore();
const chatStore = useChatStore();
// refuse
@ -686,8 +686,8 @@ function playAudio(url) {
}
//
console.log('语音功能状态:', audioStore.isVoiceEnabled);
if (!audioStore.isVoiceEnabled) {
console.log('语音功能状态:', emotionAudioStore.isVoiceEnabled);
if (!emotionAudioStore.isVoiceEnabled) {
console.log('语音功能已关闭,跳过播放');
return;
}
@ -696,11 +696,11 @@ function playAudio(url) {
try {
// URL
audioStore.setCurrentAudioUrl(url);
emotionAudioStore.setCurrentAudioUrl(url);
//
if (audioStore.nowSound && audioStore.nowSound.playing()) {
audioStore.nowSound.stop();
if (emotionAudioStore.nowSound && emotionAudioStore.nowSound.playing()) {
emotionAudioStore.nowSound.stop();
}
//
@ -710,41 +710,41 @@ function playAudio(url) {
format: ['mp3', 'wav'],
onplay: () => {
isAudioPlaying.value = true;
audioStore.isPlaying = true;
emotionAudioStore.isPlaying = true;
console.log('开始播放场景应用语音');
},
onend: () => {
isAudioPlaying.value = false;
audioStore.isPlaying = false;
audioStore.isPaused = false;
audioStore.playbackPosition = 0;
emotionAudioStore.isPlaying = false;
emotionAudioStore.isPaused = false;
emotionAudioStore.playbackPosition = 0;
console.log('场景应用语音播放结束');
},
onstop: () => {
isAudioPlaying.value = false;
audioStore.isPlaying = false;
emotionAudioStore.isPlaying = false;
console.log('场景应用语音播放停止');
},
onpause: () => {
isAudioPlaying.value = false;
audioStore.isPlaying = false;
emotionAudioStore.isPlaying = false;
console.log('场景应用语音播放暂停');
},
onerror: (error) => {
isAudioPlaying.value = false;
audioStore.isPlaying = false;
emotionAudioStore.isPlaying = false;
console.error('音频播放错误:', error);
},
onload: () => {
//
audioStore.duration = newSound.duration();
console.log('音频加载完成,时长:', audioStore.duration);
emotionAudioStore.duration = newSound.duration();
console.log('音频加载完成,时长:', emotionAudioStore.duration);
}
});
// store
audioStore.nowSound = newSound;
audioStore.setAudioInstance(newSound);
emotionAudioStore.nowSound = newSound;
emotionAudioStore.setAudioInstance(newSound);
//
newSound.play();
@ -757,8 +757,8 @@ function playAudio(url) {
//
function stopAudio() {
if (audioStore.nowSound) {
audioStore.nowSound.stop();
if (emotionAudioStore.nowSound) {
emotionAudioStore.nowSound.stop();
}
isAudioPlaying.value = false;
}

8
src/views/components/marketTemperature.vue

@ -189,10 +189,10 @@ function initChart(raw, klineDataRawValue, WDRLValue) {
maxPrice = Math.max(maxPrice, high)
})
// 10
const yAxisMin = Math.floor(minPrice / 10) * 10
// 10
const yAxisMax = Math.ceil(maxPrice / 10) * 10 + 10
// y
const yAxisMin = Math.floor(minPrice)
// y
const yAxisMax = Math.ceil(maxPrice)
//
WDRL.value = WDRLValue

20
src/views/homePage.vue

@ -10,7 +10,7 @@ import Feedback from "./Feedback.vue";
import { useAppBridge } from "../assets/js/useAppBridge.js";
import { useDataStore } from "@/store/dataList.js";
import { useChatStore } from "../store/chat";
import { useAudioStore } from "../store/audio";
import { useEmotionAudioStore } from "../store/emotionAudio";
import _ from "lodash";
import logo from "../assets/img/homePage/logo.png";
@ -43,20 +43,20 @@ const dataStore = useDataStore();
const chatStore = useChatStore();
//
//
const audioStore = useAudioStore();
const isVoice = computed(() => audioStore.isVoiceEnabled);
const emotionAudioStore = useEmotionAudioStore();
const isVoice = computed(() => emotionAudioStore.isVoiceEnabled);
const toggleVoice = () => {
if (!audioStore.isVoiceEnabled) {
if (!emotionAudioStore.isVoiceEnabled) {
//
audioStore.toggleVoice();
emotionAudioStore.toggleVoice();
} else {
// /
if (audioStore.currentAudioUrl || audioStore.ttsUrl) {
if (emotionAudioStore.currentAudioUrl || emotionAudioStore.ttsUrl) {
// /
audioStore.togglePlayPause();
emotionAudioStore.togglePlayPause();
} else {
//
audioStore.toggleVoice();
emotionAudioStore.toggleVoice();
}
}
};
@ -605,8 +605,8 @@ onMounted(async () => {
<!-- AI情绪大模型按钮 -->
<img :src="activeTab === 'AiEmotion' ? emotionButton01 : emotionButton02
" @click="setActiveTab('AiEmotion', 1)" class="action-btn model-btn" alt="AI情绪大模型" />
<img v-if="audioStore.isVoiceEnabled && !audioStore.isPlaying" :src="voice" @click="toggleVoice" class="action-btn" />
<img v-else-if="audioStore.isVoiceEnabled && audioStore.isPlaying" :src="voice" @click="toggleVoice" class="action-btn" style="opacity: 0.7; animation: pulse 1.5s infinite;" />
<img v-if="emotionAudioStore.isVoiceEnabled && !emotionAudioStore.isPlaying" :src="voice" @click="toggleVoice" class="action-btn" />
<img v-else-if="emotionAudioStore.isVoiceEnabled && emotionAudioStore.isPlaying" :src="voice" @click="toggleVoice" class="action-btn" style="opacity: 0.7; animation: pulse 1.5s infinite;" />
<img v-else :src="voiceNoActive" @click="toggleVoice" class="action-btn" />
</div>
</div>

Loading…
Cancel
Save