From 858b9bccead46cdefc99325b7c956d50a2964309 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期六, 08 三月 2025 10:20:28 +0800 Subject: [PATCH] 一些优化 --- src/views/demo/feat/download/index.vue | 70 ++++++++++++++-------------------- 1 files changed, 29 insertions(+), 41 deletions(-) diff --git a/src/views/demo/feat/download/index.vue b/src/views/demo/feat/download/index.vue index 159b1e8..79aa2d8 100644 --- a/src/views/demo/feat/download/index.vue +++ b/src/views/demo/feat/download/index.vue @@ -1,66 +1,54 @@ <template> <PageWrapper title="鏂囦欢涓嬭浇绀轰緥"> - <a-alert message="鏍规嵁鍚庡彴鎺ュ彛鏂囦欢娴佷笅杞�" /> + <Alert message="鏍规嵁鍚庡彴鎺ュ彛鏂囦欢娴佷笅杞�" /> <a-button type="primary" class="my-4" @click="handleDownByData"> 鏂囦欢娴佷笅杞� </a-button> - <a-alert message="鏍规嵁鏂囦欢鍦板潃涓嬭浇鏂囦欢" /> + <Alert message="鏍规嵁鏂囦欢鍦板潃涓嬭浇鏂囦欢" /> <a-button type="primary" class="my-4" @click="handleDownloadByUrl"> 鏂囦欢鍦板潃涓嬭浇 </a-button> - <a-alert message="base64娴佷笅杞�" /> + <Alert message="base64娴佷笅杞�" /> <a-button type="primary" class="my-4" @click="handleDownloadByBase64"> base64娴佷笅杞� </a-button> - <a-alert message="鍥剧墖Url涓嬭浇,濡傛灉鏈夎法鍩熼棶棰橈紝闇�瑕佸鐞嗗浘鐗囪法鍩�" /> + <Alert message="鍥剧墖Url涓嬭浇,濡傛灉鏈夎法鍩熼棶棰橈紝闇�瑕佸鐞嗗浘鐗囪法鍩�" /> <a-button type="primary" class="my-4" @click="handleDownloadByOnlineUrl"> 鍥剧墖Url涓嬭浇 </a-button> </PageWrapper> </template> -<script lang="ts"> - import { defineComponent } from 'vue'; +<script lang="ts" setup> import { downloadByUrl, downloadByData, downloadByBase64, downloadByOnlineUrl, - } from '/@/utils/file/download'; + } from '@/utils/file/download'; import imgBase64 from './imgBase64'; - import { PageWrapper } from '/@/components/Page'; + import { PageWrapper } from '@/components/Page'; import { Alert } from 'ant-design-vue'; - export default defineComponent({ - components: { PageWrapper, [Alert.name]: Alert }, - setup() { - function handleDownByData() { - downloadByData('text content', 'testName.txt'); - } - function handleDownloadByUrl() { - downloadByUrl({ - url: 'https://codeload.github.com/anncwb/vue-vben-admin-doc/zip/master', - target: '_self', - }); + function handleDownByData() { + downloadByData('text content', 'testName.txt'); + } + function handleDownloadByUrl() { + downloadByUrl({ + url: 'https://codeload.github.com/anncwb/vue-vben-admin-doc/zip/master', + target: '_self', + }); - downloadByUrl({ - url: 'https://vebn.oss-cn-beijing.aliyuncs.com/vben/logo.png', - target: '_self', - }); - } + downloadByUrl({ + url: 'https://vebn.oss-cn-beijing.aliyuncs.com/vben/logo.png', + target: '_self', + }); + } - function handleDownloadByBase64() { - downloadByBase64(imgBase64, 'logo.png'); - } + function handleDownloadByBase64() { + downloadByBase64(imgBase64, 'logo.png'); + } - function handleDownloadByOnlineUrl() { - downloadByOnlineUrl( - 'https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/5944817f47b8408e9f1442ece49d68ca~tplv-k3u1fbpfcp-watermark.image', - 'logo.png', - ); - } - return { - handleDownloadByUrl, - handleDownByData, - handleDownloadByBase64, - handleDownloadByOnlineUrl, - }; - }, - }); + function handleDownloadByOnlineUrl() { + downloadByOnlineUrl( + 'https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/5944817f47b8408e9f1442ece49d68ca~tplv-k3u1fbpfcp-watermark.image', + 'logo.png', + ); + } </script> -- Gitblit v1.9.3