feat(admin): 转码设置页新增立即补齐转码按钮

This commit is contained in:
Zhou Weidong authored and trae-solo-agent committed 2026-10-23 14:14:46 +08:00
1 parent d7d43fed44
commit e51d371e07
7 files changed
+86 -5

No files matched your search

+14 -1
View File
@@ -1,7 +1,12 @@
// Author: fruit.com.cn
import request from '@/axios'
import type { EpisodeTranscodeItem, MediaThumbnailResult, TranscodeTriggerResult } from './types'
import type {
EpisodeTranscodeItem,
MediaThumbnailResult,
TranscodeBackfillResult,
TranscodeTriggerResult
} from './types'
/** 分集编辑页聚合查询转码任务、清晰度与帧图。 */
export const getEpisodeTranscodeApi = (episodeId: number | string) => {
@@ -28,3 +33,11 @@ export const triggerMediaTranscodeApi = (mediaAssetId: string) => {
url: `/admin/media/${mediaAssetId}/transcode`
})
}
/** 手动补齐转码:扫描缺码率产物/帧图的分集并入队。 */
export const runTranscodeBackfillApi = (batchSize?: number) => {
return request.post<TranscodeBackfillResult>({
url: '/admin/media/transcode/backfill',
params: batchSize ? { batchSize } : undefined
})
}
+10
View File
@@ -321,6 +321,16 @@ export interface TranscodeTriggerResult {
status: string
}
export interface TranscodeBackfillItem {
episodeId: string
taskId: string
}
export interface TranscodeBackfillResult {
triggered: number
items: TranscodeBackfillItem[]
}
export interface BannerItem {
id: number
imageUrl: string
+5
View File
@@ -657,6 +657,11 @@ export default {
saveFailed: 'Failed to save transcode settings',
loadFailed: 'Failed to load transcode settings',
noPermission: 'This account cannot manage transcode settings',
backfill: 'Backfill transcodes',
backfillTip: 'Scan episodes missing renditions or thumbnails and enqueue them for transcoding',
backfillDone: 'Enqueued {count} episodes into the transcode queue',
backfillEmpty: 'No episodes need transcoding',
backfillFailed: 'Failed to run transcode backfill',
enabled: 'Enable transcode profile',
enabledDescription:
'Marks whether this transcode profile is enabled; the quality ladder is still validated when saved.',
+5
View File
@@ -648,6 +648,11 @@ export default {
saveFailed: '转码设置保存失败',
loadFailed: '转码设置加载失败',
noPermission: '当前账号没有转码设置权限',
backfill: '立即补齐转码',
backfillTip: '扫描缺少清晰度产物或帧图的分集并自动入队转码',
backfillDone: '本轮已补入 {count} 个分集进入转码队列',
backfillEmpty: '没有需要补转的分集',
backfillFailed: '补齐转码执行失败',
enabled: '启用转码配置',
enabledDescription: '标记当前转码配置是否启用;保存时仍会校验下方档位。',
segmentSeconds: 'HLS 分片时长(秒)',
@@ -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)
}
}