代码问题

This commit is contained in:
2025-11-23 01:02:47 +08:00
parent 4377dc8dc8
commit 8f3a73433f
4 changed files with 17 additions and 12 deletions

View File

@@ -33,15 +33,16 @@ export const ChatMessageApi = {
attachmentUrls = []
} = options || {}
const token = getAccessToken()
let retryCount = 0
const maxRetries = 0 // 禁用自动重试
return fetchEventSource(`${SERVER_BASE_AI}/chat/message/send-stream`, {
method: 'post',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${token}`
Authorization: `Bearer ${token}`,
'tenant-id': import.meta.env?.VITE_TENANT_ID
},
openWhenHidden: true,
body: JSON.stringify({

View File

@@ -18,9 +18,11 @@ export const useVoiceCopyStore = defineStore('voiceCopy', {
/**
* 加载配音列表
*/
async load() {
if (this.loaded && !this.loading) return
async load(forceRefresh = false) {
if(!forceRefresh){
if (this.loaded && !this.loading) return
}
this.loading = true
try {
const res = await VoiceService.getPage({
@@ -166,7 +168,7 @@ export const useVoiceCopyStore = defineStore('voiceCopy', {
*/
async refresh() {
this.loaded = false
await this.load()
await this.load(true)
}
}
})

View File

@@ -6,7 +6,7 @@
* 试听优化添加缓存机制同一参数下第二次试听直接播放缓存无需重复调用API
*/
defineOptions({ name: 'DigitalVideoPage' })
import { ref, computed, onMounted, watch, onUnmounted } from 'vue'
import { ref, computed, onMounted, watch, onUnmounted, onActivated } from 'vue'
import { message } from 'ant-design-vue'
import { InboxOutlined, SoundOutlined, LoadingOutlined } from '@ant-design/icons-vue'
import { VoiceService } from '@/api/voice'
@@ -40,7 +40,7 @@ const MAX_PREVIEW_CACHE_SIZE = 50 // 最多缓存50个音色的试听音频
// TTS 配置
const ttsText = ref('')
const selectedTtsVoice = ref('')
const speechRate = ref(1.5)
const speechRate = ref(1.0)
const instruction = ref('neutral') // 指令参数,用于控制音色风格
const emotion = ref('neutral') // 情感参数
const emotionActive = ref(false) // 是否激活情感tabfalse为指令true为情感
@@ -730,7 +730,8 @@ const playAudioFromBase64 = (audioBase64, format = 'mp3', onEnded = null) => {
// 生命周期
onMounted(async () => {
await voiceStore.load()
await voiceStore.refresh()
// 默认选择第一个音色
if (voiceSource.value === 'user' && userVoiceCards.value.length > 0) {
selectVoiceProfile(userVoiceCards.value[0])
@@ -742,6 +743,8 @@ onMounted(async () => {
await loadLastTask()
})
onUnmounted(() => {
// 停止音频播放
previewAudio?.pause?.()
@@ -853,7 +856,6 @@ let previewObjectUrl = ''
</div>
</div>
<div class="voice-item-meta">
<span class="voice-tag">{{ voice.category }}</span>
<a-button
size="small"
type="link"

View File

@@ -68,7 +68,7 @@
style="width: 300px"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
placeholder="['开始日期', '结束日期']"
:placeholder="['开始日期', '结束日期']"
@change="handleFilterChange"
/>
<a-button type="primary" @click="handleFilterChange">查询</a-button>