feat: 配额优化

This commit is contained in:
2026-02-25 21:30:24 +08:00
parent 2e93211697
commit 79a5c1f3ed
29 changed files with 1225 additions and 489 deletions

View File

@@ -6,6 +6,10 @@
import { ref, reactive } from 'vue'
import { message } from 'ant-design-vue'
import { MaterialService } from '@/api/material'
import { useUserStore } from '@/stores/user'
// GB转字节常量
const GB_TO_BYTES = 1073741824
/**
* 获取视频时长(秒)
@@ -140,6 +144,20 @@ export function useUpload() {
state.error = null
state.progress = 0
// 存储空间校验
const userStore = useUserStore()
const fileSizeGB = file.size / GB_TO_BYTES
const remainingStorage = userStore.remainingStorage || 0
if (fileSizeGB > remainingStorage) {
const error = new Error(`存储空间不足!需要 ${fileSizeGB.toFixed(2)} GB剩余 ${remainingStorage.toFixed(2)} GB`)
state.uploading = false
state.status = 'error'
state.error = error.message
onError?.(error)
throw error
}
// 通知开始
onStart?.()