From db3092db2eb7d5346778847757adb2b9c4041ed5 Mon Sep 17 00:00:00 2001 From: vben <anncwb@126.com> Date: 星期五, 13 十一月 2020 00:55:25 +0800 Subject: [PATCH] feat: add file download demo --- src/router/menus/modules/demo/feat.ts | 10 ++++++++++ src/router/routes/modules/demo/feat.ts | 8 ++++++++ src/utils/file/FileDownload.ts | 1 + src/views/demo/feat/download/index.vue | 32 ++++++++++++++++++++++++++++++++ CHANGELOG.zh_CN.md | 1 + src/components/registerGlobComp.ts | 2 ++ 6 files changed, 54 insertions(+), 0 deletions(-) diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md index 4e4556a..e857fc2 100644 --- a/CHANGELOG.zh_CN.md +++ b/CHANGELOG.zh_CN.md @@ -12,6 +12,7 @@ - 鑿滃崟鏂板 tag 鏄剧ず锛屾敮鎸� 4 涓被鍨嬮鑹插強 dot 鍦嗙偣鏄剧ず - 鏂板鑿滃崟鍙婇《鏍忛鑹查�夋嫨閰嶈壊 - 澧炲姞绀轰緥缁撴灉椤� +- 鏂板鏂囦欢涓嬭浇绀轰緥 ### 鈿� Wip diff --git a/src/components/registerGlobComp.ts b/src/components/registerGlobComp.ts index 669e1b9..9655f7b 100644 --- a/src/components/registerGlobComp.ts +++ b/src/components/registerGlobComp.ts @@ -6,6 +6,7 @@ // Optional Select, + Alert, Checkbox, DatePicker, Radio, @@ -48,6 +49,7 @@ // If you don鈥檛 need it, you can delete it getApp() .use(Select) + .use(Alert) .use(Checkbox) .use(DatePicker) .use(Radio) diff --git a/src/router/menus/modules/demo/feat.ts b/src/router/menus/modules/demo/feat.ts index ca09716..d923fa1 100644 --- a/src/router/menus/modules/demo/feat.ts +++ b/src/router/menus/modules/demo/feat.ts @@ -4,6 +4,9 @@ menu: { name: '鍔熻兘', path: '/feat', + tag: { + dot: true, + }, children: [ { path: 'icon', @@ -18,6 +21,13 @@ name: '鍙抽敭鑿滃崟', }, { + path: 'download', + name: '鏂囦欢涓嬭浇', + tag: { + content: 'new', + }, + }, + { path: 'click-out-side', name: 'ClickOutSide', }, diff --git a/src/router/routes/modules/demo/feat.ts b/src/router/routes/modules/demo/feat.ts index ba5c834..6b16f82 100644 --- a/src/router/routes/modules/demo/feat.ts +++ b/src/router/routes/modules/demo/feat.ts @@ -41,6 +41,14 @@ }, }, { + path: '/download', + name: 'DownLoadDemo', + component: () => import('/@/views/demo/feat/download/index.vue'), + meta: { + title: '鏂囦欢涓嬭浇', + }, + }, + { path: '/click-out-side', name: 'ClickOutSideDemo', component: () => import('/@/views/demo/feat/click-out-side/index.vue'), diff --git a/src/utils/file/FileDownload.ts b/src/utils/file/FileDownload.ts index 9a10c0a..bb0d369 100644 --- a/src/utils/file/FileDownload.ts +++ b/src/utils/file/FileDownload.ts @@ -25,6 +25,7 @@ window.URL.revokeObjectURL(blobURL); } } + /** * 鏍规嵁鏂囦欢鍦板潃涓嬭浇鏂囦欢 * @param {*} sUrl diff --git a/src/views/demo/feat/download/index.vue b/src/views/demo/feat/download/index.vue new file mode 100644 index 0000000..2b404ab --- /dev/null +++ b/src/views/demo/feat/download/index.vue @@ -0,0 +1,32 @@ +<template> + <div class="m-5 demo-box"> + <a-alert message="鏍规嵁鍚庡彴鎺ュ彛鏂囦欢娴佷笅杞�" /> + <a-button type="primary" class="my-4" @click="handleDownByData"> 鏂囦欢娴佷笅杞� </a-button> + + <a-alert message="鏍规嵁鏂囦欢鍦板潃涓嬭浇鏂囦欢" /> + + <a-button type="primary" class="my-4" @click="handleDownloadByUrl"> 鏂囦欢鍦板潃涓嬭浇 </a-button> + </div> +</template> +<script lang="ts"> + import { defineComponent } from 'vue'; + import { downloadByUrl, downloadByData } from '/@/utils/file/FileDownload'; + + export default defineComponent({ + 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', + }); + } + return { + handleDownloadByUrl, + handleDownByData, + }; + }, + }); +</script> -- Gitblit v1.8.0