From 57e11a51624033db3f46167b1501728d34c615b1 Mon Sep 17 00:00:00 2001 From: Weidi Deng Date: Thu, 17 Dec 2020 11:04:52 +0800 Subject: [PATCH] use header component to select multiple files to download --- frontend/src/api/files.js | 7 +- frontend/src/api/utils.js | 2 + frontend/src/components/Header.vue | 26 ++++++- frontend/src/components/buttons/Download.vue | 12 ++- frontend/src/components/prompts/Download.vue | 14 +++- frontend/src/css/mobile.css | 12 +-- frontend/src/store/getters.js | 1 + frontend/src/store/index.js | 3 + frontend/src/store/mutations.js | 13 +++- frontend/src/views/Share.vue | 81 +++++++++----------- 10 files changed, 107 insertions(+), 64 deletions(-) diff --git a/frontend/src/api/files.js b/frontend/src/api/files.js index 08f0d84a..a06469a7 100644 --- a/frontend/src/api/files.js +++ b/frontend/src/api/files.js @@ -58,7 +58,8 @@ export async function put (url, content = '') { } export function download (format, ...files) { - let url = `${baseURL}/api/raw` + const isSharing = store.getters['isSharing'] + let url = isSharing ? `${baseURL}/api/public/dl/${store.state.shared.hash}` : `${baseURL}/api/raw` if (files.length === 1) { url += removePrefix(files[0]) + '?' @@ -78,7 +79,9 @@ export function download (format, ...files) { url += `algo=${format}&` } - url += `auth=${store.state.jwt}` + if (!isSharing) { + url += `auth=${store.state.jwt}` + } window.open(url) } diff --git a/frontend/src/api/utils.js b/frontend/src/api/utils.js index 617e2258..b6c41037 100644 --- a/frontend/src/api/utils.js +++ b/frontend/src/api/utils.js @@ -36,6 +36,8 @@ export async function fetchJSON (url, opts) { export function removePrefix (url) { if (url.startsWith('/files')) { url = url.slice(6) + } else if (store.getters['isSharing']) { + url = url.slice(7 + store.state.shared.hash.length) } if (url === '') url = '/' diff --git a/frontend/src/components/Header.vue b/frontend/src/components/Header.vue index b9278d10..7829fa7d 100644 --- a/frontend/src/components/Header.vue +++ b/frontend/src/components/Header.vue @@ -28,7 +28,7 @@ -