From 4e6ba39822c5e7ad86d53f32dbd215a6340d2044 Mon Sep 17 00:00:00 2001 From: IlyaL Date: Sat, 24 May 2025 02:06:39 +0800 Subject: [PATCH 1/2] feat: add copy link button --- app/layouts/default.vue | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/app/layouts/default.vue b/app/layouts/default.vue index f5a446b..4122864 100644 --- a/app/layouts/default.vue +++ b/app/layouts/default.vue @@ -49,6 +49,23 @@ const ssr = useRouteQuery('ssr', 'false', { const prod = useRouteQuery('prod', 'false', { transform: stringToBooleanTransformer, }) + +const toast = useToast() +const { copy } = useClipboard() + +async function copyLink(e: MouseEvent) { + if (e.metaKey) { + // hidden logic for going to local debug from playground.vueuse.org + window.location.href = `http://localhost:3000/${window.location.hash}` + return + } + copy(location.href) + toast.add({ + title: 'Sharable URL has been copied to clipboard.', + icon: 'i-heroicons-check-circle', + color: 'success', + }) +}