Browse Source

Add and copy the OneTimeLink after it is generated.

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

31
src/app/components/ClientCard/OneTimeLinkBtn.vue

@ -12,6 +12,12 @@
const props = defineProps<{ client: LocalClient }>();
const clientsStore = useClientsStore();
const toast = useToast();
const { copy, copied, isSupported } = useClipboard();
const oneTimeLink = computed(
() =>
`${document.location.protocol}//${document.location.host}/cnf/${props.client.oneTimeLink.oneTimeLink}`
);
const _showOneTimeLink = useSubmit(
`/api/client/${props.client.id}/generateOneTimeLink`,
@ -21,11 +27,36 @@ const _showOneTimeLink = useSubmit(
{
revert: async () => {
await clientsStore.refresh();
await copyOneTimeLink();
},
noSuccessToast: true,
}
);
async function copyOneTimeLink() {
if (!isSupported) {
toast.showToast({
type: 'error',
message: $t('copy.noSupport'),
});
return;
}
await nextTick();
await copy(oneTimeLink.value);
if (!copied.value) {
toast.showToast({
type: 'error',
message: $t('copy.error'),
});
return;
}
toast.showToast({
type: 'success',
message: $t('copy.success'),
});
}
function showOneTimeLink() {
return _showOneTimeLink(undefined);
}

5
src/i18n/locales/en.json

@ -237,5 +237,10 @@
"postUp": "PostUp",
"preDown": "PreDown",
"postDown": "PostDown"
},
"copy": {
"noSupport": "Copy not supported",
"success": "Copied",
"error": "Copy failed"
}
}

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

@ -233,5 +233,10 @@
"postUp": "启动后脚本",
"preDown": "停止前脚本",
"postDown": "停止后脚本"
},
"copy": {
"no_support": "当前浏览器不支持复制",
"success": "复制成功",
"error": "复制失败"
}
}

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

@ -234,5 +234,10 @@
"postUp": "PostUp",
"preDown": "PreDown",
"postDown": "PostDown"
},
"copy": {
"noSupport": "目前瀏覽器不支援複製",
"success": "複製成功",
"error": "複製失敗"
}
}

Loading…
Cancel
Save