Deploy v4.6.18 download overlay completion fix
Browse files- README.md +1 -1
- VERSION +1 -1
- static/js/app.js +23 -2
- static/js/project-package.js +2 -2
- tests/test_download_overlay_v4618.py +21 -0
README.md
CHANGED
|
@@ -10,7 +10,7 @@ pinned: false
|
|
| 10 |
|
| 11 |
# Global Marine Foundation Data Agent
|
| 12 |
|
| 13 |
-
Current UI release: **v4.6.
|
| 14 |
|
| 15 |
|
| 16 |
## v3.4.0 稳定性重构(第一阶段)
|
|
|
|
| 10 |
|
| 11 |
# Global Marine Foundation Data Agent
|
| 12 |
|
| 13 |
+
Current UI release: **v4.6.18**.
|
| 14 |
|
| 15 |
|
| 16 |
## v3.4.0 稳定性重构(第一阶段)
|
VERSION
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
4.6.
|
|
|
|
| 1 |
+
4.6.18
|
static/js/app.js
CHANGED
|
@@ -2701,6 +2701,25 @@ function triggerBrowserSave(url,filename){
|
|
| 2701 |
setTimeout(()=>a.remove(),0);
|
| 2702 |
}
|
| 2703 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2704 |
function downloadFetchUrl(sourceUrl){
|
| 2705 |
const u=new URL(sourceUrl,location.href);
|
| 2706 |
if(u.protocol==="blob:"||u.protocol==="data:"||u.origin===location.origin)return u.href;
|
|
@@ -2722,6 +2741,7 @@ function saveBlobWithProgress(blob,filename="download",options={}){
|
|
| 2722 |
const obj=URL.createObjectURL(blob);
|
| 2723 |
triggerBrowserSave(obj,filename);
|
| 2724 |
setTimeout(()=>URL.revokeObjectURL(obj),3000);
|
|
|
|
| 2725 |
return true;
|
| 2726 |
}
|
| 2727 |
|
|
@@ -2763,9 +2783,10 @@ async function downloadWithProgress(url,filename="download",options={}){
|
|
| 2763 |
$("downloadProgressHint").textContent=err.message||"请重新生成数据包";
|
| 2764 |
throw err
|
| 2765 |
}
|
| 2766 |
-
$("downloadProgressState").textContent="浏览器
|
| 2767 |
-
$("downloadProgressHint").textContent="文件已验证,
|
| 2768 |
triggerBrowserSave(sourceUrl,filename);
|
|
|
|
| 2769 |
return true;
|
| 2770 |
}
|
| 2771 |
|
|
|
|
| 2701 |
setTimeout(()=>a.remove(),0);
|
| 2702 |
}
|
| 2703 |
|
| 2704 |
+
function finishNativeBrowserDownloadUi(filename="download"){
|
| 2705 |
+
const overlay=$("downloadProgressOverlay"),bar=$("downloadProgressBar");
|
| 2706 |
+
if(!overlay||!bar)return;
|
| 2707 |
+
bar.classList.remove("indeterminate","error");
|
| 2708 |
+
bar.classList.add("done");
|
| 2709 |
+
bar.style.width="100%";
|
| 2710 |
+
$("downloadProgressState").textContent="已交给浏览器";
|
| 2711 |
+
$("downloadProgressAmount").textContent="浏览器管理";
|
| 2712 |
+
$("downloadProgressSpeed").textContent="—";
|
| 2713 |
+
$("downloadProgressElapsed").textContent="—";
|
| 2714 |
+
$("downloadProgressHint").textContent="下载已由浏览器接管;实际完成状态以浏览器下载栏为准。";
|
| 2715 |
+
$("downloadProgressCancel").disabled=true;
|
| 2716 |
+
$("downloadProgressCancel").textContent="已交给浏览器";
|
| 2717 |
+
clearTimeout(window.__nativeDownloadOverlayTimer);
|
| 2718 |
+
window.__nativeDownloadOverlayTimer=setTimeout(()=>{
|
| 2719 |
+
overlay.classList.remove("show");
|
| 2720 |
+
},1800);
|
| 2721 |
+
}
|
| 2722 |
+
|
| 2723 |
function downloadFetchUrl(sourceUrl){
|
| 2724 |
const u=new URL(sourceUrl,location.href);
|
| 2725 |
if(u.protocol==="blob:"||u.protocol==="data:"||u.origin===location.origin)return u.href;
|
|
|
|
| 2741 |
const obj=URL.createObjectURL(blob);
|
| 2742 |
triggerBrowserSave(obj,filename);
|
| 2743 |
setTimeout(()=>URL.revokeObjectURL(obj),3000);
|
| 2744 |
+
setTimeout(()=>$("downloadProgressOverlay")?.classList.remove("show"),1800);
|
| 2745 |
return true;
|
| 2746 |
}
|
| 2747 |
|
|
|
|
| 2783 |
$("downloadProgressHint").textContent=err.message||"请重新生成数据包";
|
| 2784 |
throw err
|
| 2785 |
}
|
| 2786 |
+
$("downloadProgressState").textContent="正在交给浏览器";
|
| 2787 |
+
$("downloadProgressHint").textContent="文件已验证,浏览器将接管实际传输;完成状态以浏览器下载栏为准。";
|
| 2788 |
triggerBrowserSave(sourceUrl,filename);
|
| 2789 |
+
finishNativeBrowserDownloadUi(filename);
|
| 2790 |
return true;
|
| 2791 |
}
|
| 2792 |
|
static/js/project-package.js
CHANGED
|
@@ -56,7 +56,7 @@ async function renderProjectPackage(){
|
|
| 56 |
if(!url)return;
|
| 57 |
try{
|
| 58 |
await downloadWithProgress(url,"project_data_package.zip",{title:"正在重新下载项目数据包"});
|
| 59 |
-
toast("已交给浏览器下载")
|
| 60 |
}catch(err){
|
| 61 |
toast(err.status===410||err.status===404?"历史数据包已过期,请点击“重新生成”":"重新下载失败:"+(err.message||String(err)))
|
| 62 |
}
|
|
@@ -196,7 +196,7 @@ async function renderProjectPackage(){
|
|
| 196 |
const btn=$("packageDownload");btn.disabled=true;btn.textContent="正在交给浏览器…";
|
| 197 |
try{
|
| 198 |
await downloadWithProgress(r.download_url,"project_data_package.zip",{title:"正在下载项目数据包"});
|
| 199 |
-
toast("已交给浏览器
|
| 200 |
}catch(err){
|
| 201 |
toast("下载失败:"+(err.message||String(err)));
|
| 202 |
}finally{
|
|
|
|
| 56 |
if(!url)return;
|
| 57 |
try{
|
| 58 |
await downloadWithProgress(url,"project_data_package.zip",{title:"正在重新下载项目数据包"});
|
| 59 |
+
toast("已交给浏览器;实际完成状态请看浏览器下载栏")
|
| 60 |
}catch(err){
|
| 61 |
toast(err.status===410||err.status===404?"历史数据包已过期,请点击“重新生成”":"重新下载失败:"+(err.message||String(err)))
|
| 62 |
}
|
|
|
|
| 196 |
const btn=$("packageDownload");btn.disabled=true;btn.textContent="正在交给浏览器…";
|
| 197 |
try{
|
| 198 |
await downloadWithProgress(r.download_url,"project_data_package.zip",{title:"正在下载项目数据包"});
|
| 199 |
+
toast("已交给浏览器;实际完成状态请看浏览器下载栏");
|
| 200 |
}catch(err){
|
| 201 |
toast("下载失败:"+(err.message||String(err)));
|
| 202 |
}finally{
|
tests/test_download_overlay_v4618.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from pathlib import Path
|
| 2 |
+
ROOT=Path(__file__).resolve().parents[1]
|
| 3 |
+
|
| 4 |
+
def test_version():
|
| 5 |
+
assert (ROOT/"VERSION").read_text(encoding="utf-8").strip()=="4.6.18"
|
| 6 |
+
|
| 7 |
+
def test_native_download_handoff_finishes_overlay():
|
| 8 |
+
js=(ROOT/"static/js/app.js").read_text(encoding="utf-8")
|
| 9 |
+
assert "finishNativeBrowserDownloadUi" in js
|
| 10 |
+
assert 'textContent="已交给浏览器"' in js
|
| 11 |
+
assert 'overlay.classList.remove("show")' in js
|
| 12 |
+
assert "1800" in js
|
| 13 |
+
|
| 14 |
+
def test_same_origin_calls_finish_helper():
|
| 15 |
+
js=(ROOT/"static/js/app.js").read_text(encoding="utf-8")
|
| 16 |
+
block=js[js.index("if(new URL(sourceUrl).origin===location.origin)"):js.index("const overlay=ensureDownloadProgressUi();",js.index("if(new URL(sourceUrl).origin===location.origin)")+1)]
|
| 17 |
+
assert "finishNativeBrowserDownloadUi(filename)" in block
|
| 18 |
+
|
| 19 |
+
def test_project_package_copy_is_truthful():
|
| 20 |
+
js=(ROOT/"static/js/project-package.js").read_text(encoding="utf-8")
|
| 21 |
+
assert "实际完成状态请看浏览器下载栏" in js
|