Commit 75d73c97 by lijiabin

【代码优化】 refactor: 上传视频流程结束后统一释放临时视频地址,避免资源长期占用

parent 235266d5
......@@ -152,14 +152,15 @@ let cancelUploadController = () => {}
const startUpload = async () => {
if (!currentFile.value) return
let localVideoUrl = ''
try {
uploading.value = true
uploadError.value = ''
uploadProgress.value = 0
// 先提案获取视频的原信息 用本地blob
const blob = URL.createObjectURL(currentFile.value)
const metadataPromise = getVideoMetadata(blob)
localVideoUrl = URL.createObjectURL(currentFile.value)
const metadataPromise = getVideoMetadata(localVideoUrl)
const { promise, cancel } = uploadFileApi(currentFile.value, {
onProgress: (progress) => {
uploadProgress.value = progress
......@@ -198,6 +199,10 @@ const startUpload = async () => {
uploading.value = false
uploadError.value = error instanceof Error ? error.message : '上传失败,请重试'
push.error(uploadError.value)
} finally {
if (localVideoUrl) {
URL.revokeObjectURL(localVideoUrl)
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment