From 5668a4dfcb4882745d8af6800023e111e5dcfe8e Mon Sep 17 00:00:00 2001 From: Rabbit_PL Date: Wed, 21 Mar 2018 12:37:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?refactor(KLImagePreview):=20=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E9=A2=84=E8=A7=88=E4=B8=8B=E8=BD=BDdownload=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/js/components/widget/KLImagePreview/index.html | 2 +- src/js/components/widget/KLImagePreview/index.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/js/components/widget/KLImagePreview/index.html b/src/js/components/widget/KLImagePreview/index.html index 2d6aca01..ca5eb680 100644 --- a/src/js/components/widget/KLImagePreview/index.html +++ b/src/js/components/widget/KLImagePreview/index.html @@ -15,7 +15,7 @@ {#list opList as op}
  • {#if (imageList[curIndex].status === 'success' || imageList[curIndex].status === undefined) && op.name === 'remove'} - + {#elseif op.name === 'zoomIn'} {parseInt(virtualInfo.scale * 100)}% diff --git a/src/js/components/widget/KLImagePreview/index.js b/src/js/components/widget/KLImagePreview/index.js index cbf2a973..ae75f3d1 100644 --- a/src/js/components/widget/KLImagePreview/index.js +++ b/src/js/components/widget/KLImagePreview/index.js @@ -348,6 +348,16 @@ const KLImagePreview = Component.extend({ minTranslateY: minDeltaY < 0 ? minDeltaY : 0, }; }, + downloadFile(file) { + const a = document.createElement('a'); + a.download = file.name; + fetch(file.url).then(res => res.blob().then((blob) => { + const blobUrl = window.URL.createObjectURL(blob); + a.href = blobUrl; + a.click(); + window.URL.revokeObjectURL(blobUrl); + })); + }, }); module.exports = KLImagePreview; From 3bc244a23a025da53fb5b112d7635ff76e223f36 Mon Sep 17 00:00:00 2001 From: Rabbit_PL Date: Wed, 21 Mar 2018 14:01:34 +0800 Subject: [PATCH 2/2] =?UTF-8?q?refactor(KLImagePreview):=20=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E9=A2=84=E8=A7=88=E4=B8=8B=E8=BD=BDurl=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2=E4=B8=BAsrc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/source/doc.js | 2 +- src/js/components/widget/KLImagePreview/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/doc.js b/doc/source/doc.js index fb8b7048..279cb171 100644 --- a/doc/source/doc.js +++ b/doc/source/doc.js @@ -108,7 +108,7 @@ const doc = (isDev, callback) => { // 组件文档 CATES.forEach((c) => { const components = getComponents(c.cate).filter((comp) => { - if (isDev && !/^KL(Sidebar|Menu|Button|Table|Select|MultiSelect)$/.test(comp)) { + if (isDev && !/^KL(Sidebar|Upload|Menu|Button|Table|Select|MultiSelect)$/.test(comp)) { return false; } diff --git a/src/js/components/widget/KLImagePreview/index.js b/src/js/components/widget/KLImagePreview/index.js index ae75f3d1..2e12b427 100644 --- a/src/js/components/widget/KLImagePreview/index.js +++ b/src/js/components/widget/KLImagePreview/index.js @@ -351,7 +351,7 @@ const KLImagePreview = Component.extend({ downloadFile(file) { const a = document.createElement('a'); a.download = file.name; - fetch(file.url).then(res => res.blob().then((blob) => { + fetch(file.src).then(res => res.blob().then((blob) => { const blobUrl = window.URL.createObjectURL(blob); a.href = blobUrl; a.click();