🐛 修复上传阶段状态与重试进度
补齐预签名和分片上传的初始化、上传、确认、成功与失败状态回调,使用实际上传对象的进度字节避免 ZIP 选中文件计数失真,并在新提交前清理旧错误状态。 - 空提交校验不再进入 uploading 状态,失败保留文件以便重试 - 完成架构检查、类型检查和生产构建验证
This commit is contained in:
1 parent
84ddf92b20
commit
43ebc8c1b2
4 files changed
+32
-14
No files matched your search
@@ -12,9 +12,9 @@ type UseSendSubmitOptions = {
|
||||
getMaxFileSize: () => number
|
||||
notify: (message: string, type: AlertType) => void
|
||||
translate: Translate
|
||||
onProgress: (progress: number) => void
|
||||
onProgress: (progress: UploadProgress) => void
|
||||
onHashCalculated: (hash: string) => void
|
||||
onStatus?: (status: 'idle' | 'uploading' | 'success' | 'error') => void
|
||||
onStatus?: (status: 'idle' | 'initializing' | 'uploading' | 'confirming' | 'success' | 'error') => void
|
||||
}
|
||||
|
||||
type SubmitFileOptions = {
|
||||
@@ -35,7 +35,8 @@ type SubmitTextOptions = {
|
||||
export function useSendSubmit(options: UseSendSubmitOptions) {
|
||||
const { uploadFile: presignUploadFile, reset: resetPresignUpload } = usePresignedUpload({
|
||||
getMaxFileSize: options.getMaxFileSize,
|
||||
notify: options.notify
|
||||
notify: options.notify,
|
||||
onStatus: options.onStatus
|
||||
})
|
||||
|
||||
const handleChunkUpload = async (
|
||||
@@ -47,9 +48,8 @@ export function useSendSubmit(options: UseSendSubmitOptions) {
|
||||
expireValue,
|
||||
expireStyle,
|
||||
onHashCalculated: options.onHashCalculated,
|
||||
onProgress: (progress: UploadProgress) => {
|
||||
options.onProgress(progress.percentage)
|
||||
},
|
||||
onProgress: options.onProgress,
|
||||
onStatus: options.onStatus,
|
||||
messages: {
|
||||
initFailed: options.translate('send.messages.initChunkUploadFailed'),
|
||||
chunkFailed: (index) => options.translate('send.messages.chunkUploadFailed', { index }),
|
||||
@@ -67,7 +67,7 @@ export function useSendSubmit(options: UseSendSubmitOptions) {
|
||||
expireValue,
|
||||
expireStyle: expireStyle as ExpireStyle,
|
||||
onProgress: (progress) => {
|
||||
options.onProgress(progress.percentage)
|
||||
options.onProgress(progress)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -107,7 +107,7 @@ export function useSendSubmit(options: UseSendSubmitOptions) {
|
||||
throw new Error(options.translate('send.messages.selectFile'))
|
||||
}
|
||||
|
||||
options.onStatus?.('uploading')
|
||||
|
||||
try {
|
||||
const response = enableChunk
|
||||
? await handleChunkUpload(fileToUpload, expireValue, expireStyle)
|
||||
|
||||
Reference in new issue
Block a user