feat(SRTEditor): 添加导出视频功能的状态管理

This commit is contained in:
2025-01-06 14:31:50 +08:00
parent e4917d0053
commit becab7b07c

View File

@@ -27,6 +27,7 @@ const isSaving = ref(false)
const rawSrt = ref<string | null>(null) const rawSrt = ref<string | null>(null)
const subtitles = ref<Subtitle[]>([]) const subtitles = ref<Subtitle[]>([])
const modified = ref(false) const modified = ref(false)
const isExporting = ref(false)
const videoElement = ref<HTMLVideoElement | null>(null) const videoElement = ref<HTMLVideoElement | null>(null)
@@ -175,7 +176,7 @@ const saveNewSubtitle = () => {
} }
const exportVideo = () => { const exportVideo = () => {
isSaving.value = true isExporting.value = true
useVideoSubtitleEmbedding(props.course.video_url, props.course.subtitle_url, { useVideoSubtitleEmbedding(props.course.video_url, props.course.subtitle_url, {
color: subtitleStyleState.color, color: subtitleStyleState.color,
fontSize: subtitleStyleState.fontSize, fontSize: subtitleStyleState.fontSize,
@@ -196,7 +197,7 @@ const exportVideo = () => {
const { download } = useDownload(blobUrl, 'combined_video.mp4') const { download } = useDownload(blobUrl, 'combined_video.mp4')
download() download()
}).finally(() => { }).finally(() => {
isSaving.value = false isExporting.value = false
}) })
} }
@@ -219,7 +220,7 @@ defineExpose({
<template> <template>
<div> <div>
<USlideover v-model="isDrawerActive" :ui="{ width: 'max-w-xl' }"> <USlideover v-model="isDrawerActive" :prevent-close="modified" :ui="{ width: 'max-w-xl' }">
<UCard class="flex flex-col flex-1 overflow-hidden" :ui="{ <UCard class="flex flex-col flex-1 overflow-hidden" :ui="{
body: { base: 'overflow-auto flex-1' }, body: { base: 'overflow-auto flex-1' },
ring: '', ring: '',
@@ -356,10 +357,10 @@ defineExpose({
<template #footer> <template #footer>
<div class="flex justify-end items-center gap-2"> <div class="flex justify-end items-center gap-2">
<span v-if="modified" class="text-sm text-yellow-500 font-medium">已更改但未保存</span> <span v-if="modified" class="text-sm text-yellow-500 font-medium">已更改但未保存</span>
<UButton :loading="isSaving" variant="soft" icon="i-tabler-file-export" @click="exportVideo"> <UButton :loading="isExporting" variant="soft" icon="i-tabler-file-export" @click="exportVideo">
导出视频 导出视频
</UButton> </UButton>
<UButton :disabled="!modified" :loading="isSaving" icon="i-tabler-device-floppy" @click="saveNewSubtitle"> <UButton :disabled="isExporting || !modified" :loading="isSaving" icon="i-tabler-device-floppy" @click="saveNewSubtitle">
保存{{ isSaving ? '' : '' }} 保存{{ isSaving ? '' : '' }}
</UButton> </UButton>
</div> </div>