hookehuyr

上传组件点击查看现有文件时操作逻辑优化

<!--
* @Date: 2022-08-31 16:16:49
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-07-27 08:22:39
* @LastEditTime: 2024-07-27 13:07:02
* @FilePath: /data-table/src/components/FileUploaderField/index.vue
* @Description: 文件上传控件
-->
......@@ -54,13 +54,20 @@
<van-divider />
</div>
<div v-else style="padding: 1rem;">
<a
<!-- <a
v-for="(item, index) in default_file" :key="index"
:href="item.url"
:download="item.name"
style="color: #000; font-size: 0.9rem; text-decoration: underline; margin-right: 0.5rem;"
>
{{ item.name }}
</a> -->
<a
@click="downloadFile(item)"
v-for="(item, index) in default_file" :key="index"
style="color: #000; font-size: 0.9rem; text-decoration: underline; margin-right: 0.5rem; cursor:pointer;"
>
{{ item.name }}
</a>
</div>
</div>
......@@ -87,6 +94,7 @@ import BMF from "browser-md5-file";
import { useRoute } from "vue-router";
import axios from "axios";
import { getEtag } from "@/utils/qetag.js"; // 生成hash值
import { wxInfo } from "@/utils/tools";
const $route = useRoute();
const props = defineProps({
......@@ -107,6 +115,16 @@ onMounted(() => {
}
})
const downloadFile = (item) => {
if (wxInfo().isWeiXin) {
// 在微信内置浏览器中,直接跳转到手机自带浏览器中下载文件
window.location.href = item.url;
} else {
// 不在微信内置浏览器中,直接打开下载链接
window.open(item.url, '_blank');
}
}
// 文件类型中文页面显示
const type_text = computed(() => {
return props.item.component_props.file_type;
......