From a4ef02a47b53742a0ac1f639563b0c67116619c8 Mon Sep 17 00:00:00 2001 From: Yeicor <4929005+Yeicor@users.noreply.github.com> Date: Mon, 1 May 2023 13:07:01 +0200 Subject: [PATCH] feat: add option to copy download links from shares (#2442) --- frontend/src/components/prompts/Share.vue | 20 +++++++++++++- frontend/src/i18n/en.json | 1 + frontend/src/views/Share.vue | 33 +++++++++++++++++++++-- 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/prompts/Share.vue b/frontend/src/components/prompts/Share.vue index 210b2f93..c0c3c083 100644 --- a/frontend/src/components/prompts/Share.vue +++ b/frontend/src/components/prompts/Share.vue @@ -32,6 +32,16 @@ content_paste + + + { + this.$showSuccess(this.$t("success.linkCopied")); + }); }, beforeDestroy() { window.removeEventListener("keydown", this.keyEvent); + this.clip.destroy(); }, computed: { ...mapState(["req", "loading", "multiple", "selected"]), - ...mapGetters(["selectedCount", "selectedCount"]), + ...mapGetters(["selectedCount"]), icon: function () { if (this.req.isDir) return "folder"; if (this.req.type === "image") return "insert_photo"; @@ -300,8 +316,13 @@ export default { toggleMultipleSelection() { this.$store.commit("multiple", !this.multiple); }, + isSingleFile: function () { + return ( + this.selectedCount === 1 && !this.req.items[this.selected[0]].isDir + ); + }, download() { - if (this.selectedCount === 1 && !this.req.items[this.selected[0]].isDir) { + if (this.isSingleFile()) { api.download( null, this.hash, @@ -326,6 +347,14 @@ export default { }, }); }, + linkSelected: function () { + return this.isSingleFile() + ? api.getDownloadURL({ + hash: this.hash, + path: this.req.items[this.selected[0]].path, + }) + : ""; + }, }, };