From 259902a7ea9c7cd57cde572a791a66296f05e3b4 Mon Sep 17 00:00:00 2001 From: carlossa Date: Thu, 18 Jan 2024 14:59:51 +0100 Subject: [PATCH] refs #6339 composable --- src/components/UserPanel.vue | 36 ++++++++++++++++----------------- src/components/ui/VnLv.vue | 20 +++++++++--------- src/composables/useClipboard.js | 17 ++++++++++++++++ 3 files changed, 44 insertions(+), 29 deletions(-) create mode 100644 src/composables/useClipboard.js diff --git a/src/components/UserPanel.vue b/src/components/UserPanel.vue index f512ac4c4..e0b6b86ed 100644 --- a/src/components/UserPanel.vue +++ b/src/components/UserPanel.vue @@ -1,19 +1,19 @@ @@ -129,8 +125,12 @@ function copyUserToken(){
{{ user.nickname }}
-
@{{ user.name }} -
+
+ @{{ user.name }} +
diff --git a/src/components/ui/VnLv.vue b/src/components/ui/VnLv.vue index 6edfb8526..0e4a055eb 100644 --- a/src/components/ui/VnLv.vue +++ b/src/components/ui/VnLv.vue @@ -1,9 +1,8 @@ @@ -62,7 +60,7 @@ function copyText() { -
+
diff --git a/src/composables/useClipboard.js b/src/composables/useClipboard.js new file mode 100644 index 000000000..008c24fa1 --- /dev/null +++ b/src/composables/useClipboard.js @@ -0,0 +1,17 @@ +import { useQuasar } from 'quasar'; +import { useI18n } from 'vue-i18n'; + +export function useClipboard() { + const quasar = useQuasar(); + const { t } = useI18n(); + /** + * + * @param {String} value Value to send to clipboardAPI + * @param {Object} {label, component} Refer to Quasar notify configuration. Label is the text to translate + */ + function copyText(value, { label = 'components.VnLv.copyText', component = {} }) { + navigator.clipboard.writeText(value); + quasar.notify({ type: 'positive', message: t(label, component) }); + } + return { copyText }; +}