feat: 配额优化

This commit is contained in:
2026-02-25 21:30:24 +08:00
parent 2e93211697
commit 79a5c1f3ed
29 changed files with 1225 additions and 489 deletions

View File

@@ -6,7 +6,7 @@
* 试听优化添加缓存机制同一参数下第二次试听直接播放缓存无需重复调用API
*/
defineOptions({ name: 'DigitalVideoPage' })
import { ref, computed, onMounted, watch, onUnmounted, onActivated } from 'vue'
import { ref, computed, onMounted, watch, onUnmounted } from 'vue'
import { message } from 'ant-design-vue'
import { InboxOutlined, SoundOutlined, LoadingOutlined } from '@ant-design/icons-vue'
import { VoiceService } from '@/api/voice'
@@ -18,7 +18,9 @@ import { DEFAULT_VOICE_PROVIDER } from '@/config/voiceConfig'
// 导入 voiceStore 用于获取用户音色
import { useVoiceCopyStore } from '@/stores/voiceCopy'
import { usePointsConfigStore } from '@/stores/pointsConfig'
const voiceStore = useVoiceCopyStore()
const pointsConfigStore = usePointsConfigStore()
// 状态管理
const uploadedVideo = ref('')
@@ -36,6 +38,10 @@ const playingPreviewVoiceId = ref('') // 当前正在试听的音色ID
const isPlayingSynthesized = ref(false) // 是否正在播放已合成的音频
const pollingInterval = ref(null) // 轮询间隔ID
// 音频播放实例
let previewAudio = null
let previewObjectUrl = ''
// Upload Hook
const { upload } = useUpload()
@@ -760,6 +766,8 @@ const playAudioFromBase64 = (audioBase64, format = 'mp3', onEnded = null) => {
// 生命周期
onMounted(async () => {
// 加载积分配置
pointsConfigStore.loadConfig()
await voiceStore.refresh()
// 默认选择第一个音色
@@ -830,9 +838,6 @@ watch([ttsText, speechRate, instruction, emotion], () => {
console.log('试听参数已变化,清除缓存')
})
// 音频实例
let previewAudio = null
let previewObjectUrl = ''
</script>
<template>
@@ -1032,6 +1037,7 @@ let previewObjectUrl = ''
>
{{ isGenerating ? '生成中...' : '生成视频' }}
</a-button>
<p class="points-hint">生成视频将消耗积分,消耗量与视频时长相关</p>
</div>
<div v-else class="task-actions">
@@ -1440,6 +1446,13 @@ let previewObjectUrl = ''
gap: 12px;
}
.points-hint {
text-align: center;
font-size: 12px;
color: #94a3b8;
margin: 0;
}
.task-actions {
display: flex;
flex-direction: column;