feat(admin): 转码设置页新增立即补齐转码按钮
This commit is contained in:
1 parent
d7d43fed44
commit
e51d371e07
7 files changed
+86
-5
No files matched your search
@@ -14,6 +14,7 @@ const {
|
||||
rules,
|
||||
loading,
|
||||
saving,
|
||||
backfilling,
|
||||
loadError,
|
||||
canManage,
|
||||
qualityRules,
|
||||
@@ -23,7 +24,8 @@ const {
|
||||
loadProfile,
|
||||
addRung,
|
||||
deleteRung,
|
||||
saveProfile
|
||||
saveProfile,
|
||||
runBackfill
|
||||
} = useTranscodeSettings()
|
||||
</script>
|
||||
|
||||
@@ -33,6 +35,18 @@ const {
|
||||
:title="t('transcodeSettings.title')"
|
||||
:description="t('transcodeSettings.description')"
|
||||
>
|
||||
<el-tooltip :content="t('transcodeSettings.backfillTip')" placement="top">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
:loading="backfilling"
|
||||
:disabled="!canManage || loading"
|
||||
@click="runBackfill"
|
||||
>
|
||||
<AppIcon v-if="!backfilling" :icon="AppIcons.videoPlay" />
|
||||
{{ t('transcodeSettings.backfill') }}
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
<el-button :disabled="loading" @click="loadProfile">
|
||||
<AppIcon :icon="AppIcons.refresh" />
|
||||
{{ t('transcodeSettings.reload') }}
|
||||
|
||||
@@ -5,6 +5,7 @@ import type { ComputedRef, Ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import { getMediaTranscodeProfileApi, saveMediaTranscodeProfileApi } from '@/api/admin/media'
|
||||
import { runTranscodeBackfillApi } from '@/api/admin/transcode'
|
||||
import type { MediaTranscodeProfile } from '@/api/admin/types'
|
||||
import { applyProfileToForm, buildProfilePayload } from './transcodeProfileModel'
|
||||
|
||||
@@ -15,6 +16,7 @@ interface SettingsContext {
|
||||
formRef: Ref<FormInstance | undefined>
|
||||
loading: Ref<boolean>
|
||||
saving: Ref<boolean>
|
||||
backfilling: Ref<boolean>
|
||||
loadError: Ref<string>
|
||||
canManage: ComputedRef<boolean>
|
||||
t: Translate
|
||||
@@ -77,3 +79,28 @@ export const saveTranscodeProfile = async (context: SettingsContext): Promise<vo
|
||||
context.saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 手动补齐转码:扫一遍缺码率产物/帧图的分集并入队。 */
|
||||
export const runTranscodeBackfill = async (context: SettingsContext): Promise<void> => {
|
||||
if (!context.canManage.value || context.backfilling.value) {
|
||||
return
|
||||
}
|
||||
context.backfilling.value = true
|
||||
try {
|
||||
const response = await runTranscodeBackfillApi()
|
||||
if (response.code !== 0) {
|
||||
ElMessage.error(response.message || context.t('transcodeSettings.backfillFailed'))
|
||||
return
|
||||
}
|
||||
const triggered = response.data?.triggered ?? 0
|
||||
if (triggered > 0) {
|
||||
ElMessage.success(context.t('transcodeSettings.backfillDone', { count: triggered }))
|
||||
} else {
|
||||
ElMessage.info(context.t('transcodeSettings.backfillEmpty'))
|
||||
}
|
||||
} catch {
|
||||
ElMessage.error(context.t('transcodeSettings.backfillFailed'))
|
||||
} finally {
|
||||
context.backfilling.value = false
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,11 @@ import {
|
||||
positiveEvenRule,
|
||||
positiveIntegerRule
|
||||
} from './transcodeProfileRules'
|
||||
import { loadTranscodeProfile, saveTranscodeProfile } from './transcodeSettingsActions'
|
||||
import {
|
||||
loadTranscodeProfile,
|
||||
runTranscodeBackfill,
|
||||
saveTranscodeProfile
|
||||
} from './transcodeSettingsActions'
|
||||
|
||||
/** 转码设置页的响应式状态与动作装配。 */
|
||||
export function useTranscodeSettings() {
|
||||
@@ -22,10 +26,11 @@ export function useTranscodeSettings() {
|
||||
const formRef = ref<FormInstance>()
|
||||
const loading = ref(false)
|
||||
const saving = ref(false)
|
||||
const backfilling = ref(false)
|
||||
const loadError = ref('')
|
||||
const form = reactive<MediaTranscodeProfile>(defaultProfile())
|
||||
const canManage = computed(() => can('episode:upload'))
|
||||
const context = { form, formRef, loading, saving, loadError, canManage, t }
|
||||
const context = { form, formRef, loading, saving, backfilling, loadError, canManage, t }
|
||||
const rules = computed(() => createProfileRules(t))
|
||||
const enabledRules = computed(() => createEnabledRules(form, t))
|
||||
const qualityRules = (index: number) => createQualityRules(form, index, t)
|
||||
@@ -50,6 +55,7 @@ export function useTranscodeSettings() {
|
||||
rules,
|
||||
loading,
|
||||
saving,
|
||||
backfilling,
|
||||
loadError,
|
||||
canManage,
|
||||
qualityRules,
|
||||
@@ -59,6 +65,7 @@ export function useTranscodeSettings() {
|
||||
loadProfile,
|
||||
addRung,
|
||||
deleteRung,
|
||||
saveProfile
|
||||
saveProfile,
|
||||
runBackfill: () => runTranscodeBackfill(context)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user