feat: 优化
This commit is contained in:
@@ -47,7 +47,7 @@
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, onMounted, onBeforeUnmount, nextTick, watch } from 'vue'
|
||||
import { Empty } from 'ant-design-vue'
|
||||
import { Empty, message } from 'ant-design-vue'
|
||||
import { SoundOutlined } from '@ant-design/icons-vue'
|
||||
import { useVoiceCopyStore } from '@/stores/voiceCopy'
|
||||
import { useTTS, TTS_PROVIDERS } from '@/composables/useTTS'
|
||||
@@ -205,6 +205,14 @@ const initPlayer = (url) => {
|
||||
|
||||
nextTick(() => {
|
||||
try {
|
||||
// 检查容器是否存在
|
||||
if (!playerContainer.value) {
|
||||
message.error('播放器容器未就绪')
|
||||
isPlayerInitializing.value = false
|
||||
audioUrl.value = ''
|
||||
return
|
||||
}
|
||||
|
||||
player = new APlayer({
|
||||
container: playerContainer.value,
|
||||
autoplay: true,
|
||||
@@ -225,6 +233,7 @@ const initPlayer = (url) => {
|
||||
|
||||
player.on('error', (e) => {
|
||||
console.error('APlayer 播放错误:', e)
|
||||
message.error('音频播放失败,请重试')
|
||||
})
|
||||
|
||||
player.on('canplay', () => {
|
||||
@@ -232,7 +241,9 @@ const initPlayer = (url) => {
|
||||
})
|
||||
} catch (e) {
|
||||
console.error('APlayer 初始化失败:', e)
|
||||
message.error('播放器初始化失败,请重试')
|
||||
isPlayerInitializing.value = false
|
||||
audioUrl.value = ''
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user