From 868fd0658cd34d9a99ae8cd44cae9b5db27d0105 Mon Sep 17 00:00:00 2001 From: sion123 <450702724@qq.com> Date: Sun, 5 Apr 2026 17:30:47 +0800 Subject: [PATCH] feat: add video file size validation with 100MB limit in digital human store Add MAX_VIDEO_SIZE constant and implement file size validation for both upload and selection workflows to comply with 302.ai Kling API limitations. Display error toast when files exceed the 100MB threshold before processing. --- .../views/kling/stores/useDigitalHumanStore.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/frontend/app/web-gold/src/views/kling/stores/useDigitalHumanStore.ts b/frontend/app/web-gold/src/views/kling/stores/useDigitalHumanStore.ts index 8ed6d3ad25..ad06fe3114 100644 --- a/frontend/app/web-gold/src/views/kling/stores/useDigitalHumanStore.ts +++ b/frontend/app/web-gold/src/views/kling/stores/useDigitalHumanStore.ts @@ -17,6 +17,11 @@ import { useUpload } from '@/composables/useUpload' import { DEFAULT_VOICE_PROVIDER } from '@/config/voiceConfig' import type { VoiceMeta, Video, PipelinePhase, VideoStep, AudioStep, CreateStep, TimelineData } from '../types/identify-face' +// ========== 常量 ========== + +/** 视频文件大小上限 100MB(302.ai Kling 接口限制) */ +const MAX_VIDEO_SIZE = 100 * 1024 * 1024 + // ========== 内部类型定义 ========== /** 音频数据 */ @@ -235,6 +240,11 @@ export const useDigitalHumanStore = defineStore('digitalHuman', () => { return } + if (file.size > MAX_VIDEO_SIZE) { + toast.error('视频文件不能超过 100MB') + return + } + // 释放旧的 blob URL if (videoPreviewUrl.value?.startsWith('blob:')) { URL.revokeObjectURL(videoPreviewUrl.value) @@ -251,6 +261,12 @@ export const useDigitalHumanStore = defineStore('digitalHuman', () => { /** 从素材库选择视频(选择后自动识别) */ async function selectVideo(video: Video) { + // 校验视频大小 + if (video.fileSize && video.fileSize > MAX_VIDEO_SIZE) { + toast.error('视频文件不能超过 100MB') + return + } + selectedVideo.value = video videoFile.value = null videoSource.value = 'select'