Browse Source

only copy when using https and show an err msg on first copy

pull/2252/head
yuWorm 8 months ago
parent
commit
da8fd56949
  1. 13
      src/app/components/ClientCard/OneTimeLinkBtn.vue
  2. 3
      src/i18n/locales/en.json
  3. 3
      src/i18n/locales/zh-CN.json
  4. 3
      src/i18n/locales/zh-HK.json

13
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',

3
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"
}
}

3
src/i18n/locales/zh-CN.json

@ -237,6 +237,7 @@
"copy": {
"no_support": "当前浏览器不支持复制",
"success": "复制成功",
"error": "复制失败"
"error": "复制失败",
"onlyHttps": "仅在HTTPS下支持自动复制"
}
}

3
src/i18n/locales/zh-HK.json

@ -238,6 +238,7 @@
"copy": {
"noSupport": "目前瀏覽器不支援複製",
"success": "複製成功",
"error": "複製失敗"
"error": "複製失敗",
"onlyHttps": "僅在HTTPS下支援自動複製"
}
}

Loading…
Cancel
Save