diff --git a/src/app/components/ClientCard/OneTimeLinkBtn.vue b/src/app/components/ClientCard/OneTimeLinkBtn.vue index c6da4475..c24fe0fe 100644 --- a/src/app/components/ClientCard/OneTimeLinkBtn.vue +++ b/src/app/components/ClientCard/OneTimeLinkBtn.vue @@ -14,6 +14,7 @@ const props = defineProps<{ client: LocalClient }>(); const clientsStore = useClientsStore(); const toast = useToast(); const { copy, copied, isSupported } = useClipboard(); +const isFirstCopy = ref(true); const _showOneTimeLink = useSubmit( `/api/client/${props.client.id}/generateOneTimeLink`, @@ -30,6 +31,18 @@ const _showOneTimeLink = useSubmit( ); async function copyOneTimeLink() { + // only copy when using https, since the browser blocks clipboard access on http. + if (window.location.protocol !== 'https:') { + if (isFirstCopy.value) { + toast.showToast({ + type: 'error', + message: $t('copy.onlyHttps'), + }); + isFirstCopy.value = false; + } + return; + } + if (!isSupported) { toast.showToast({ type: 'error', diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index 38b84942..2d0096a2 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -241,6 +241,7 @@ "copy": { "noSupport": "Copy not supported", "success": "Copied", - "error": "Copy failed" + "error": "Copy failed", + "onlyHttps": "Only in HTTPS support automatic copy" } } diff --git a/src/i18n/locales/zh-CN.json b/src/i18n/locales/zh-CN.json index a966a0cd..40f91b91 100644 --- a/src/i18n/locales/zh-CN.json +++ b/src/i18n/locales/zh-CN.json @@ -237,6 +237,7 @@ "copy": { "no_support": "当前浏览器不支持复制", "success": "复制成功", - "error": "复制失败" + "error": "复制失败", + "onlyHttps": "仅在HTTPS下支持自动复制" } } diff --git a/src/i18n/locales/zh-HK.json b/src/i18n/locales/zh-HK.json index 56286c5b..b21f2f53 100644 --- a/src/i18n/locales/zh-HK.json +++ b/src/i18n/locales/zh-HK.json @@ -238,6 +238,7 @@ "copy": { "noSupport": "目前瀏覽器不支援複製", "success": "複製成功", - "error": "複製失敗" + "error": "複製失敗", + "onlyHttps": "僅在HTTPS下支援自動複製" } }