feat(front): enhance file hash calculation by introducing engine selection for large files using native or wasm methods

This commit is contained in:
keven1024
2026-04-08 23:45:34 +08:00
parent f1dc65b1d0
commit ae2fbcc216
3 changed files with 27 additions and 37 deletions

View File

@@ -137,11 +137,14 @@ watchEffect(async () => {
}
})
const LARGE_FILE_THRESHOLD = 500 * 1024 * 1024 // 500 MB
const handleHash = async (fileId: string) => {
const uploadfile = uploadfiles.value.find((item) => item.fileId === fileId)
if (!uploadfile?.file) return
uploadfile.procressType = 'hash'
const res = await asyncWorker(calcFileHashWorker, { data: { file: uploadfile.file } })
const engine = uploadfile.file.size >= LARGE_FILE_THRESHOLD ? 'wasm' : 'native'
const res = await asyncWorker(calcFileHashWorker, { data: { file: uploadfile.file, engine } })
const { hash } = res?.data || {}
uploadfile.hash = hash
}