diff --git a/src/composables/usePresignedUpload.ts b/src/composables/usePresignedUpload.ts index 1852395..bd3e153 100644 --- a/src/composables/usePresignedUpload.ts +++ b/src/composables/usePresignedUpload.ts @@ -74,7 +74,6 @@ export function usePresignedUpload() { const isError = computed(() => presignStatus.value === PRESIGN_UPLOAD_STATUS.ERROR) const currentMode = computed(() => uploadSession.value?.mode ?? null) - /** * 文件大小验证 */ @@ -144,7 +143,6 @@ export function usePresignedUpload() { alertStore.showAlert(errorMessage.value, 'error') } - /** * 初始化上传会话 */ @@ -224,7 +222,6 @@ export function usePresignedUpload() { } } - /** * 代理模式上传 */ @@ -263,30 +260,19 @@ export function usePresignedUpload() { } } - /** - * 上传文件(主入口方法) - * 根据 mode 自动选择直传或代理上传 - */ - const uploadFile = async ( - file: File, - options?: PresignUploadOptions - ): Promise => { - // 重置状态 + const uploadFile = async (file: File, options?: PresignUploadOptions): Promise => { reset() - // 验证文件大小 if (!validateFileSize(file)) { presignStatus.value = PRESIGN_UPLOAD_STATUS.ERROR return null } - // 初始化上传会话 const session = await initUploadSession(file, options) if (!session) { return null } - // 根据模式选择上传方式 if (session.mode === 'direct') { return await uploadDirect(file, session, options) } else { @@ -294,7 +280,6 @@ export function usePresignedUpload() { } } - /** * 取消上传 */ diff --git a/src/types/index.ts b/src/types/index.ts index 6dfd698..00169ab 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -179,7 +179,6 @@ export interface RouteConfig { } } - // ==================== 预签名上传相关类型 ==================== // 预签名上传模式 diff --git a/src/views/SendFileView.vue b/src/views/SendFileView.vue index cd265d7..dc886fd 100644 --- a/src/views/SendFileView.vue +++ b/src/views/SendFileView.vue @@ -1029,16 +1029,10 @@ const handleSubmit = async () => { let response: ApiResponse if (sendType.value === 'file') { - // 优先使用预签名上传,如果失败则回退到其他方式 - try { + if (config.enableChunk) { + response = await handleChunkUpload(selectedFile.value!) + } else { response = await handlePresignedUpload(selectedFile.value!) - } catch { - // 预签名上传失败,回退到切片上传或默认上传 - if (config.enableChunk) { - response = await handleChunkUpload(selectedFile.value!) - } else { - response = await handleDefaultFileUpload(selectedFile.value!) - } } } else { // 文本上传保持不变