Browse Source
温度计y轴刻度值修改,最小值向下取整,最大值向上取整;独立两个模型的音频仓库文件;
hongxilin/hotfix-20250625101643-手机输入法弹出输入框上浮
温度计y轴刻度值修改,最小值向下取整,最大值向上取整;独立两个模型的音频仓库文件;
hongxilin/hotfix-20250625101643-手机输入法弹出输入框上浮
4 changed files with 123 additions and 34 deletions
-
89src/store/emotionAudio.js
-
40src/views/AiEmotion.vue
-
8src/views/components/marketTemperature.vue
-
20src/views/homePage.vue
@ -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 = '' |
||||
|
} |
||||
|
} |
||||
|
}) |
||||
|
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue