|
@@ -82,8 +82,8 @@
|
|
|
<script setup>
|
|
|
import { ref } from 'vue';
|
|
|
// import { onMounted, reactive } from "vue";
|
|
|
-// import { isWechat } from '../../utils/isTerminal';
|
|
|
-// import { showToast } from 'vant';
|
|
|
+import { isWechat } from '../../utils/isTerminal';
|
|
|
+import { showToast } from 'vant';
|
|
|
const main = ref(null);
|
|
|
const image = ref({
|
|
|
width: 0,
|
|
@@ -145,31 +145,31 @@ const onLoad = e => {
|
|
|
};
|
|
|
};
|
|
|
|
|
|
-const down = item => {
|
|
|
-// if (isWechat) return showToast('请使用浏览器打开本页面');
|
|
|
- fetch(item.downUrl)
|
|
|
- .then(response => {
|
|
|
- // 确保服务器返回的是blob类型的数据
|
|
|
- if (!response.ok) {
|
|
|
- throw new Error('Network response was not ok');
|
|
|
- }
|
|
|
- return response.blob();
|
|
|
- })
|
|
|
- .then(blob => {
|
|
|
- // 创建一个可下载的链接
|
|
|
- const url = URL.createObjectURL(blob);
|
|
|
- const a = document.createElement('a');
|
|
|
- a.href = url;
|
|
|
- a.download = item.title || 'download.docx'; // 如果未指定文件名,则默认为'download.docx'
|
|
|
- a.style.display = 'none';
|
|
|
- document.body.appendChild(a);
|
|
|
- a.click();
|
|
|
- window.URL.revokeObjectURL(url); // 释放URL对象
|
|
|
- document.body.removeChild(a);
|
|
|
- })
|
|
|
- .catch(error => {
|
|
|
- console.error('Error downloading file:', error);
|
|
|
- });
|
|
|
+const down = () => {
|
|
|
+ if (isWechat) return showToast('请使用浏览器打开本页面');
|
|
|
+// fetch(item.downUrl)
|
|
|
+// .then(response => {
|
|
|
+// // 确保服务器返回的是blob类型的数据
|
|
|
+// if (!response.ok) {
|
|
|
+// throw new Error('Network response was not ok');
|
|
|
+// }
|
|
|
+// return response.blob();
|
|
|
+// })
|
|
|
+// .then(blob => {
|
|
|
+// // 创建一个可下载的链接
|
|
|
+// const url = URL.createObjectURL(blob);
|
|
|
+// const a = document.createElement('a');
|
|
|
+// a.href = url;
|
|
|
+// a.download = item.title || 'download.docx'; // 如果未指定文件名,则默认为'download.docx'
|
|
|
+// a.style.display = 'none';
|
|
|
+// document.body.appendChild(a);
|
|
|
+// a.click();
|
|
|
+// window.URL.revokeObjectURL(url); // 释放URL对象
|
|
|
+// document.body.removeChild(a);
|
|
|
+// })
|
|
|
+// .catch(error => {
|
|
|
+// console.error('Error downloading file:', error);
|
|
|
+// });
|
|
|
};
|
|
|
</script>
|
|
|
<style>
|