fix: use xhr.upload.onloadend to correctly show compressing stage

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Your Name 2026-01-31 21:27:45 +08:00
parent acc9407ec7
commit 4e42b3e1c1

View File

@ -2748,15 +2748,17 @@ export function AdminSettingsClient() {
if (event.lengthComputable) {
const percent = Math.round((event.loaded / event.total) * 100);
setVideoUploadPercent(percent);
if (percent < 100) {
setVideoUploadProgress(`上传中 ${percent}%`);
} else {
setVideoUploadStage("compressing");
setVideoUploadProgress("压缩处理中...");
}
setVideoUploadProgress(`上传中 ${percent}%`);
}
};
// 上传完成后,切换到压缩阶段
xhr.upload.onloadend = () => {
setVideoUploadPercent(100);
setVideoUploadStage("compressing");
setVideoUploadProgress("压缩处理中...");
};
xhr.onload = () => {
if (xhr.status >= 200 && xhr.status < 300) {
try {
@ -2765,6 +2767,7 @@ export function AdminSettingsClient() {
reject(new Error(response.error));
} else {
setVideoUploadStage("done");
setVideoUploadProgress("完成!");
resolve(response);
}
} catch {