feat: add video file size validation with 100MB limit in digital human store
Some checks failed
Build and Deploy / deploy (push) Has been cancelled
Some checks failed
Build and Deploy / deploy (push) Has been cancelled
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.
This commit is contained in:
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user