文件下载提交

This commit is contained in:
frank wang 2025-10-13 19:43:10 +08:00
parent 04b4e489e4
commit 4964c7e207
1 changed files with 10 additions and 3 deletions

View File

@ -207,9 +207,7 @@ public class FirstActivity extends BaseActivity {
private boolean isDownloadUrl(String url) { private boolean isDownloadUrl(String url) {
if (TextUtils.isEmpty(url)) return false; if (TextUtils.isEmpty(url)) return false;
return true; return true;
// return url.endsWith(".pdf") // return url.endsWith(".pdf")
// || url.endsWith(".doc") // || url.endsWith(".doc")
// || url.endsWith(".docx") // || url.endsWith(".docx")
@ -263,6 +261,15 @@ public class FirstActivity extends BaseActivity {
// 保持空实现 // 保持空实现
} }
// 新增供前端H5调用下载
@JavascriptInterface
public void downloadFile(String url) {
FirstActivity activity = activityRef.get();
if (activity != null && !TextUtils.isEmpty(url)) {
activity.runOnUiThread(() -> activity.downloadFile(url));
}
}
@JavascriptInterface @JavascriptInterface
public void showLog(String message) { public void showLog(String message) {
FirstActivity activity = activityRef.get(); FirstActivity activity = activityRef.get();