From 5c1e308634298024148c0055e6821815f0887c9e Mon Sep 17 00:00:00 2001 From: "Alisa | Side.one" Date: Fri, 2 Jun 2023 12:41:47 +0800 Subject: [PATCH] feat: add copy,font weight --- src/modules/[chain]/staking/[validator].vue | 166 ++++++++++++++++---- 1 file changed, 136 insertions(+), 30 deletions(-) diff --git a/src/modules/[chain]/staking/[validator].vue b/src/modules/[chain]/staking/[validator].vue index 7f7264b2..54842878 100644 --- a/src/modules/[chain]/staking/[validator].vue +++ b/src/modules/[chain]/staking/[validator].vue @@ -135,6 +135,29 @@ onMounted(() => { }); } }); +let showCopyToast = ref(0); +const copyWebsite = async (url: string) => { + if (!url) { + return; + } + try { + await navigator.clipboard.writeText(url); + showCopyToast.value = 1; + setTimeout(() => { + showCopyToast.value = 0; + }, 1000); + } catch (err) { + showCopyToast.value = 2; + setTimeout(() => { + showCopyToast.value = 0; + }, 1000); + } +}; +const tipMsg = computed(() => { + return showCopyToast.value === 2 + ? { class: 'error', msg: 'Copy Error!' } + : { class: 'success', msg: 'Copy Success!' }; +});