fix: in-app browser download opens file inline

- Detect in-app WebViews (WeChat / TokenPocket / imToken / Telegram / iOS WKWebView, etc.) and show a guide modal asking the user to open the link in their system browser, with a copy-link action.
- For normal browsers, fetch the attachment as a Blob and trigger download from a same-origin object URL so the file always lands in the user's Downloads folder with the original filename, even when the browser would otherwise inline-preview the response.
- Fall back to the anchor download for files larger than 50MB (avoid loading them entirely into memory) or when fetch fails.
- Pass `sizeBytes` from known call sites so the threshold actually applies.
- Add localized strings for the guide modal in all 7 locales.

See .unipi/docs/debug/2026-06-05-in-app-browser-download-debug.md.
This commit is contained in:
TerryM
2026-06-05 19:06:53 +08:00
parent abfd92b16a
commit 7a33a62c8f
16 changed files with 494 additions and 106 deletions

View File

@@ -245,4 +245,16 @@ export const zhDict: Dict = {
featureUnavailableDesc: "该功能暂未开放。",
confirm: "知道了",
backToHome: "返回首页",
inAppDownloadTitle: "请使用系统浏览器打开后下载",
inAppDownloadIntro:
"当前内置浏览器无法直接下载文件请在系统浏览器Safari、Chrome 等)中打开页面后再点击下载。",
inAppDownloadIntroNamed:
"{browser} 内置浏览器无法直接下载文件请在系统浏览器Safari、Chrome 等)中打开页面后再点击下载。",
inAppDownloadStepCopy: "点击下方「复制链接」。",
inAppDownloadStepOpen:
"点右上角菜单,选择「在浏览器中打开」,如需要请把刚才复制的链接粘贴进地址栏。",
inAppDownloadStepDownload:
"在系统浏览器中再次点击下载按钮,文件会保存到下载文件夹。",
inAppDownloadCopied: "链接已复制",
inAppDownloadCopyFail: "复制失败,请手动复制",
};