hookehuyr

文件下载优化微信浏览器判断不同系统处理

<!--
* @Date: 2022-08-31 16:16:49
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-07-27 19:30:34
* @LastEditTime: 2024-07-29 14:10:48
* @FilePath: /data-table/src/components/FileUploaderField/index.vue
* @Description: 文件上传控件
-->
......@@ -69,6 +69,7 @@
>
{{ item.name }}
</a>
<a class="app-download-btn" id="BtnClick" href="javascript:;" style="display: none;"> 点此继续访问 </a>
</div>
</div>
......@@ -117,8 +118,20 @@ onMounted(() => {
const downloadFile = (item) => {
if (wxInfo().isWeiXin) {
// 在微信内置浏览器中,直接跳转到手机自带浏览器中下载文件
window.location.href = item.url;
// 安卓浏览器
if (wxInfo().isAndroid) {
var iframe = document.createElement("iframe");
iframe.style.display = "none";
iframe.src = item.url;
document.body.appendChild(iframe);
iframe.click();
}
// IOS浏览器
else if (wxInfo().isiOS) {
var entityDom = document.getElementById('BtnClick');
entityDom.href = item.url;
entityDom.click();
}
} else {
// 不在微信内置浏览器中,直接打开下载链接
fileLinkToStreamDownload(item.url, item.name, item.name.split('.').pop());
......