feat(admin): 新增转码设置页面
This commit is contained in:
1 parent
723d056fc7
commit
218196ee9f
16 files changed
+1014
-3
No files matched your search
@@ -0,0 +1,64 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import { computed, nextTick, onMounted, reactive, ref } from 'vue'
|
||||
import type { FormInstance } from 'element-plus'
|
||||
import type { MediaTranscodeProfile } from '@/api/admin/types'
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import { useRbac } from '@/stores/rbac'
|
||||
import { defaultProfile, defaultRung } from './transcodeProfileDefaults'
|
||||
import {
|
||||
createEnabledRules,
|
||||
createProfileRules,
|
||||
createQualityRules,
|
||||
positiveEvenRule,
|
||||
positiveIntegerRule
|
||||
} from './transcodeProfileRules'
|
||||
import { loadTranscodeProfile, saveTranscodeProfile } from './transcodeSettingsActions'
|
||||
|
||||
/** 转码设置页的响应式状态与动作装配。 */
|
||||
export function useTranscodeSettings() {
|
||||
const { t } = useI18n()
|
||||
const { can } = useRbac()
|
||||
const formRef = ref<FormInstance>()
|
||||
const loading = ref(false)
|
||||
const saving = 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 rules = computed(() => createProfileRules(t))
|
||||
const enabledRules = computed(() => createEnabledRules(form, t))
|
||||
const qualityRules = (index: number) => createQualityRules(form, index, t)
|
||||
|
||||
const addRung = (): void => {
|
||||
form.ladder.push(defaultRung())
|
||||
nextTick(() => formRef.value?.clearValidate())
|
||||
}
|
||||
|
||||
const deleteRung = (index: number): void => {
|
||||
form.ladder.splice(index, 1)
|
||||
nextTick(() => formRef.value?.clearValidate())
|
||||
}
|
||||
|
||||
const loadProfile = () => loadTranscodeProfile(context)
|
||||
const saveProfile = () => saveTranscodeProfile(context)
|
||||
onMounted(loadProfile)
|
||||
|
||||
return {
|
||||
form,
|
||||
formRef,
|
||||
rules,
|
||||
loading,
|
||||
saving,
|
||||
loadError,
|
||||
canManage,
|
||||
qualityRules,
|
||||
positiveEvenRule: () => positiveEvenRule(t),
|
||||
positiveIntegerRule: () => positiveIntegerRule(t),
|
||||
enabledRules,
|
||||
loadProfile,
|
||||
addRung,
|
||||
deleteRung,
|
||||
saveProfile
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user