From 5087c6c579f332eb6c9b01151eebaafea8bcac84 Mon Sep 17 00:00:00 2001 From: Weidi Deng Date: Wed, 23 Dec 2020 15:04:44 +0800 Subject: [PATCH] using existing store state and component --- frontend/src/api/files.js | 7 +- frontend/src/api/utils.js | 2 +- frontend/src/components/Header.vue | 33 ++---- frontend/src/components/buttons/Download.vue | 10 +- frontend/src/components/files/ListingItem.vue | 4 +- frontend/src/components/files/SharedItem.vue | 112 ------------------ frontend/src/components/prompts/Download.vue | 14 +-- frontend/src/css/_share.css | 6 - frontend/src/css/mobile.css | 12 +- frontend/src/store/getters.js | 5 +- frontend/src/store/index.js | 21 ++-- frontend/src/store/mutations.js | 22 +--- frontend/src/views/Share.vue | 101 ++++++++++------ 13 files changed, 104 insertions(+), 245 deletions(-) delete mode 100644 frontend/src/components/files/SharedItem.vue diff --git a/frontend/src/api/files.js b/frontend/src/api/files.js index a06469a7..b3d6575b 100644 --- a/frontend/src/api/files.js +++ b/frontend/src/api/files.js @@ -58,8 +58,7 @@ export async function put (url, content = '') { } export function download (format, ...files) { - const isSharing = store.getters['isSharing'] - let url = isSharing ? `${baseURL}/api/public/dl/${store.state.shared.hash}` : `${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]) + '?' @@ -79,9 +78,7 @@ export function download (format, ...files) { url += `algo=${format}&` } - if (!isSharing) { - url += `auth=${store.state.jwt}` - } + url += `auth=${store.state.jwt}` window.open(url) } diff --git a/frontend/src/api/utils.js b/frontend/src/api/utils.js index b6c41037..68337d10 100644 --- a/frontend/src/api/utils.js +++ b/frontend/src/api/utils.js @@ -37,7 +37,7 @@ 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) + 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 7829fa7d..ff8593ba 100644 --- a/frontend/src/components/Header.vue +++ b/frontend/src/components/Header.vue @@ -8,8 +8,8 @@
-