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

@@ -262,4 +262,16 @@ export const viDict: Dict = {
featureUnavailableDesc: "Tính năng này hiện chưa khả dụng.",
confirm: "Đã hiểu",
backToHome: "Về trang chủ",
inAppDownloadTitle: "Vui lòng mở bằng trình duyệt hệ thống để tải",
inAppDownloadIntro:
"Trình duyệt trong ứng dụng hiện tại không thể tải tệp. Hãy mở trang trong trình duyệt hệ thống (Safari, Chrome…) rồi nhấn tải lại.",
inAppDownloadIntroNamed:
"{browser} không thể tải tệp trực tiếp. Hãy mở trang trong trình duyệt hệ thống (Safari, Chrome…) rồi nhấn tải lại.",
inAppDownloadStepCopy: "Nhấn “Sao chép liên kết” bên dưới.",
inAppDownloadStepOpen:
"Mở menu ở góc trên bên phải, chọn “Mở bằng trình duyệt”, dán liên kết nếu cần.",
inAppDownloadStepDownload:
"Trong trình duyệt hệ thống, nhấn lại nút tải để lưu tệp.",
inAppDownloadCopied: "Đã sao chép liên kết",
inAppDownloadCopyFail: "Không sao chép được, vui lòng tự sao chép",
};