diff --git a/src/components/TheReviewCard.vue b/src/components/TheReviewCard.vue index 1c93776..76811df 100644 --- a/src/components/TheReviewCard.vue +++ b/src/components/TheReviewCard.vue @@ -53,9 +53,10 @@ /> - + + + + @@ -78,6 +79,8 @@ import apiClient from '@/api'; import { onMounted, onUpdated, ref, nextTick, watch } from 'vue'; import { useProfileStore } from '@/store'; import { useDisplay } from 'vuetify'; +import { useToastStore } from '@/store/toastStore'; +import { ToastType } from '@/models'; const profileStore = useProfileStore(); const { mobile } = useDisplay(); @@ -95,6 +98,7 @@ const redactedText = ref([]); const expanded = ref(false); const showExpandButton = ref(false); const commentText = ref([]); +const toastStore = useToastStore(); async function deleteComment() { await apiClient.DELETE('/rating/comment/{uuid}', { @@ -103,6 +107,37 @@ async function deleteComment() { emit('comment-deleted'); } +async function copyCommentID() { + if (!propsLocal.comment.raw.uuid) { + toastStore.push({ + title: 'Ошибка при копировании.', + type: ToastType.Error, + description: 'ID комментария не найден.', + }); + return; + } + + try { + const type = 'text/plain'; + const clipboardItemData = { + [type]: propsLocal.comment.raw.uuid, + }; + const clipboardItem = new ClipboardItem(clipboardItemData); + await navigator.clipboard.write([clipboardItem]); + + toastStore.push({ + title: 'ID комментария скопирован в буфер обмена', + type: ToastType.Info, + }); + } catch { + toastStore.push({ + title: 'Ошибка при копировании.', + type: ToastType.Error, + description: 'Не удалось скопировать ID.', + }); + } +} + function cleanupText(text: string) { return text .replace(/</g, '<')