refactor: modularize frontend flows

This commit is contained in:
Lan committed 2026-06-03 02:01:57 +08:00
1 parent 9300607f96
commit a11e7900b4
85 files changed
+4654 -4363

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
import axios from 'axios'
import type { UploadProgress } from '@/types'
export async function uploadToExternalUrl(
uploadUrl: string,
file: File,
onProgress?: (progress: UploadProgress) => void
): Promise<void> {
await axios.put(uploadUrl, file, {
headers: {
'Content-Type': 'application/octet-stream'
},
timeout: 0,
onUploadProgress: (progressEvent) => {
if (!onProgress || !progressEvent.total) {
return
}
onProgress({
loaded: progressEvent.loaded,
total: progressEvent.total,
percentage: Math.round((progressEvent.loaded * 100) / progressEvent.total)
})
}
})
}