chore: allow configuration of shortcode base (#2748)

This commit is contained in:
jerbob92
2022-10-06 21:20:48 +02:00
committed by GitHub
parent d42434ddc0
commit 7d0219b11d
4 changed files with 13 additions and 5 deletions

View File

@@ -14,8 +14,9 @@ VITE_MESSAGING_SENDER_ID=421993993223
VITE_APP_ID=1:421993993223:web:ec0baa8ee8c02ffa1fc6a2
VITE_MEASUREMENT_ID=G-BBJ3R80PJT
# Base URL
# Base URLs
VITE_BASE_URL=https://hoppscotch.io
VITE_SHORTCODE_BASE_URL=https://hopp.sh
# Backend URLs
VITE_BACKEND_GQL_URL=https://api.hoppscotch.io/graphql

View File

@@ -452,17 +452,20 @@ const copyRequest = async () => {
}
const copyShareLink = (shareLink: string) => {
const link = `${
import.meta.env.VITE_SHORTCODE_BASE_URL ?? "https://hopp.sh"
}/r${shareLink}`
if (navigator.share) {
const time = new Date().toLocaleTimeString()
const date = new Date().toLocaleDateString()
navigator.share({
title: "Hoppscotch",
text: `Hoppscotch • Open source API development ecosystem at ${time} on ${date}`,
url: `https://hopp.sh/r${shareLink}`,
url: link,
})
} else {
copyLinkIcon.value = IconCheck
copyToClipboard(`https://hopp.sh/r${shareLink}`)
copyToClipboard(link)
toast.success(`${t("state.copied_to_clipboard")}`)
}
}

View File

@@ -18,7 +18,7 @@
<ButtonSecondary
v-tippy="{ theme: 'tooltip' }"
:title="t('action.open_workspace')"
:to="`https://hopp.sh/r/${shortcode.id}`"
:to="`${shortcodeBaseURL}/r/${shortcode.id}`"
blank
:icon="IconExternalLink"
class="px-3 text-accent hover:text-accent"
@@ -105,8 +105,11 @@ const requestLabelColor = computed(() =>
const dateStamp = computed(() => shortDateTime(props.shortcode.createdOn))
const shortcodeBaseURL =
import.meta.env.VITE_SHORTCODE_BASE_URL ?? "https://hopp.sh"
const copyShortcode = (codeID: string) => {
copyToClipboard(`https://hopp.sh/r/${codeID}`)
copyToClipboard(`${shortcodeBaseURL}/r/${codeID}`)
toast.success(`${t("state.copied_to_clipboard")}`)
copyIconRefs.value = IconCheck
}

View File

@@ -16,6 +16,7 @@ interface ImportMetaEnv {
readonly VITE_MEASUREMENT_ID: string
readonly VITE_BASE_URL: string
readonly VITE_SHORTCODE_BASE_URL: string
readonly VITE_BACKEND_GQL_URL: string
readonly VITE_BACKEND_WS_URL: string