From fb5b28d9cbdee10d38fcd719b9fd832121be58ef Mon Sep 17 00:00:00 2001 From: WeidiDeng Date: Tue, 29 Dec 2020 00:35:29 +0800 Subject: [PATCH] feat: download shared subdirectory (#1184) Co-authored-by: Oleg Lobanov --- frontend/src/api/files.js | 2 +- frontend/src/api/utils.js | 2 + frontend/src/components/Header.vue | 17 +- frontend/src/components/buttons/Download.vue | 4 +- frontend/src/components/files/ListingItem.vue | 22 +- frontend/src/css/_share.css | 8 +- frontend/src/i18n/en.json | 3 +- frontend/src/i18n/zh-cn.json | 3 +- frontend/src/store/getters.js | 1 + frontend/src/store/index.js | 3 +- frontend/src/store/mutations.js | 3 +- frontend/src/views/Share.vue | 220 +++++++++++++----- http/public.go | 40 +++- 13 files changed, 240 insertions(+), 88 deletions(-) diff --git a/frontend/src/api/files.js b/frontend/src/api/files.js index 2b5cf540..d12a4237 100644 --- a/frontend/src/api/files.js +++ b/frontend/src/api/files.js @@ -58,7 +58,7 @@ export async function put (url, content = '') { } export function download (format, ...files) { - let url = `${baseURL}/api/raw` + let url = store.getters['isSharing'] ? `${baseURL}/api/public/dl/${store.state.hash}` : `${baseURL}/api/raw` if (files.length === 1) { url += removePrefix(files[0]) + '?' diff --git a/frontend/src/api/utils.js b/frontend/src/api/utils.js index 617e2258..68337d10 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.hash.length) } if (url === '') url = '/' diff --git a/frontend/src/components/Header.vue b/frontend/src/components/Header.vue index b9278d10..6d9a1270 100644 --- a/frontend/src/components/Header.vue +++ b/frontend/src/components/Header.vue @@ -8,8 +8,8 @@
-