fix copy errors in popup & console

This commit is contained in:
p0lycarpio 2025-06-30 21:05:53 +00:00
commit 1f6c9e09e3

View file

@ -24,7 +24,7 @@
{{ icon ? "" : $t("general.copy") }}
</v-btn>
</template>
<span>
<span v-if="!isSupported || copiedSuccess !== null">
<v-icon
start
dark
@ -32,7 +32,7 @@
{{ $globals.icons.clipboardCheck }}
</v-icon>
<slot v-if="!isSupported"> {{ $t("general.your-browser-does-not-support-clipboard") }} </slot>
<slot v-else> {{ copied ? $t("general.copied_message") : $t("general.clipboard-copy-failure") }} </slot>
<slot v-else> {{ copiedSuccess ? $t("general.copied_message") : $t("general.clipboard-copy-failure") }} </slot>
</span>
</v-tooltip>
</template>
@ -63,19 +63,18 @@ export default defineNuxtComponent({
const { copy, copied, isSupported } = useClipboard();
const show = ref(false);
const copyToolTip = ref<VTooltip | null>(null);
function toggleBlur() {
copyToolTip.value?.deactivate();
}
const copiedSuccess = ref<boolean | null>(null);
async function textToClipboard() {
if (isSupported.value) {
await copy(props.copyText);
if (copied.value) {
console.log(`Copied\n${props.copyText}`);
copiedSuccess.value = true;
console.info(`Copied\n${props.copyText}`);
}
else {
console.warn("Copy failed: ", copied.value);
copiedSuccess.value = false;
console.error("Copy failed: ", copied.value);
}
}
else {
@ -84,8 +83,8 @@ export default defineNuxtComponent({
show.value = true;
setTimeout(() => {
toggleBlur();
}, 500);
show.value = false;
}, 2000);
}
return {
@ -94,6 +93,7 @@ export default defineNuxtComponent({
textToClipboard,
copied,
isSupported,
copiedSuccess,
};
},
});