fix(export): offline render tu tai file ve exportDir sau khi hoan thanh

renderMasteringExport truoc day chi hien toast 'Tai ve' (phai click) ->
user tuong khong co file. Gio tu fetch res.url -> saveExportViaDialog
(ghi thang vao exportDir da chon hoac save-dialog), toast kem path.
This commit is contained in:
2026-08-24 20:54:50 +07:00
parent 4b643883ff
commit 74bd6d849b
3 changed files with 23 additions and 10 deletions
+19 -8
View File
@@ -28199,20 +28199,31 @@ const App = () => {
_lastMasterStats = { lufs: res.lufs, true_peak_db: res.true_peak_db };
const lufsTxt = (res.lufs !== null && res.lufs !== undefined) ? res.lufs + ' LUFS' : '-- LUFS';
const tpTxt = (res.true_peak_db !== null && res.true_peak_db !== undefined) ? res.true_peak_db + ' dBTP' : '-- dBTP';
showToast(`Mastering xong — ${lufsTxt} / ${tpTxt}${res.mono_warning ? ' • ' + res.mono_warning : ''}`, 'success', 'Tải về', async () => {
try {
const br = await fetch(res.url);
if (!br.ok) throw new Error('HTTP ' + br.status);
// Tự tải file về exportDir đã chọn (không chờ click "Tải về") — giống
// bounce cũ: render xong là file xuất hiện ngay.
try {
const br = await fetch(res.url);
if (br.ok) {
const b = await br.blob();
const sp = await saveExportViaDialog((projectName || 'Project') + '_master.' + outExt, b);
if (sp) showToast(`Đã lưu → ${sp}`, 'success');
} catch (e) {
if (sp) showToast(`Đã lưu → ${sp} • ${lufsTxt} / ${tpTxt}`, 'success');
else showToast(`Mastering xong — ${lufsTxt} / ${tpTxt}`, 'success');
} else {
showToast(`Mastering xong — ${lufsTxt} / ${tpTxt}`, 'success', 'Tải về', async () => {
const a = document.createElement('a');
a.href = res.url;
a.download = 'master.' + outExt;
a.click();
});
}
} catch (e) {
showToast(`Mastering xong — ${lufsTxt} / ${tpTxt}`, 'success', 'Tải về', async () => {
const a = document.createElement('a');
a.href = res.url;
a.download = 'master.' + outExt;
a.click();
}
});
});
}
} catch (e) {
showToast('Render mastering lỗi: ' + (e.message || e), 'error');
} finally {