解决不设置bgm文件夹报错

This commit is contained in:
YILS
2025-10-10 17:10:01 +08:00
parent 53e940ea4f
commit 0f880f81bb
3 changed files with 20 additions and 13 deletions

View File

@@ -64,16 +64,18 @@ const handleRenderVideo = async () => {
}
let randomBgm: ListFilesFromFolderRecord | undefined = undefined
try {
const bgmList = await window.electron.listFilesFromFolder({
folderPath: appStore.renderConfig.bgmPath.replace(/\\/g, '/'),
})
if (bgmList.length > 0) {
randomBgm = random.choice(bgmList)
if (appStore.renderConfig.bgmPath) {
try {
const bgmList = await window.electron.listFilesFromFolder({
folderPath: appStore.renderConfig.bgmPath.replace(/\\/g, '/'),
})
if (bgmList.length > 0) {
randomBgm = random.choice(bgmList)
}
} catch (error) {
console.log('获取背景音乐列表失败', error)
toast.error(t('errors.bgmListFailed'))
}
} catch (error) {
console.log('获取背景音乐列表失败', error)
toast.error(t('errors.bgmListFailed'))
}
try {