From 8a205b14d8f9d88460cfe373a84f327a6fb94331 Mon Sep 17 00:00:00 2001 From: langren1353 <1353464539@qq.com> Date: Fri, 7 Apr 2023 17:09:01 +0800 Subject: [PATCH] add Custom link Option at share panel (cherry picked from commit d7ff423e04ad0e2e66e1011c15c0eb42f8bb65ef) (cherry picked from commit 382a122847868c938ada4bcf5e2f6f8d331cb0d1) --- frontend/src/api/share.js | 29 ++++++-- frontend/src/components/prompts/Share.vue | 87 ++++++++++++++++++++--- frontend/src/i18n/ar.json | 1 + frontend/src/i18n/de.json | 1 + frontend/src/i18n/en.json | 1 + frontend/src/i18n/es.json | 1 + frontend/src/i18n/fr.json | 1 + frontend/src/i18n/he.json | 1 + frontend/src/i18n/hu.json | 1 + frontend/src/i18n/is.json | 1 + frontend/src/i18n/it.json | 1 + frontend/src/i18n/ja.json | 1 + frontend/src/i18n/ko.json | 1 + frontend/src/i18n/nl-be.json | 1 + frontend/src/i18n/pl.json | 1 + frontend/src/i18n/pt-br.json | 1 + frontend/src/i18n/pt.json | 1 + frontend/src/i18n/ro.json | 1 + frontend/src/i18n/ru.json | 1 + frontend/src/i18n/sk.json | 1 + frontend/src/i18n/sv-se.json | 1 + frontend/src/i18n/tr.json | 1 + frontend/src/i18n/ua.json | 1 + frontend/src/i18n/zh-cn.json | 1 + frontend/src/i18n/zh-tw.json | 1 + http/share.go | 16 +++-- share/share.go | 3 + 27 files changed, 141 insertions(+), 17 deletions(-) diff --git a/frontend/src/api/share.js b/frontend/src/api/share.js index 1ac4473a..bfc21d57 100644 --- a/frontend/src/api/share.js +++ b/frontend/src/api/share.js @@ -15,16 +15,37 @@ export async function remove(hash) { }); } -export async function create(url, password = "", expires = "", unit = "hours") { +export async function create( + config = { + url: "", + password: "", + expires: "", + unit: "hours", + custom: false, + customLink: "", + } +) { + let { + url, + password = "", + expires = "", + unit = "hours", + custom = false, + customLink = "", + } = config; url = removePrefix(url); url = `/api/share${url}`; if (expires !== "") { url += `?expires=${expires}&unit=${unit}`; } - let body = "{}"; - if (password != "" || expires !== "" || unit !== "hours") { - body = JSON.stringify({ password: password, expires: expires, unit: unit }); + let body = { + custom, + customLink: customLink, + }; + if (password !== "" || expires !== "" || unit !== "hours") { + Object.assign(body, { password: password, expires: expires, unit: unit }); } + body = JSON.stringify(body); return fetchJSON(url, { method: "POST", body: body, diff --git a/frontend/src/components/prompts/Share.vue b/frontend/src/components/prompts/Share.vue index 210b2f93..bc25f97e 100644 --- a/frontend/src/components/prompts/Share.vue +++ b/frontend/src/components/prompts/Share.vue @@ -68,6 +68,27 @@