diff --git a/.env.example b/.env.example index e602c48..48548f4 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,3 @@ SUPABASE_URL= -SUPABASE_KEY= \ No newline at end of file +SUPABASE_KEY= +GIPHY_API_KEY= \ No newline at end of file diff --git a/app/components/CommentReplies.vue b/app/components/CommentReplies.vue index 58660dd..164af29 100644 --- a/app/components/CommentReplies.vue +++ b/app/components/CommentReplies.vue @@ -8,6 +8,7 @@ const props = defineProps<{ replyContent: Record isReplyAnonymous: Record isSubmittingReply?: Record + openGifPicker?: (id: number) => void }>() const emit = defineEmits<{ @@ -27,7 +28,9 @@ function handleVote(replyId: number, vote: number) { } function formatMentions(content: string) { - return content.replace(/@(\S+)/g, '@$1') + let html = content.replace(/@(\S+)/g, '@$1') + html = html.replace(/!\[GIF\]\((https?:\/\/[^\s)]+)\)/g, 'GIF') + return html } @@ -100,9 +103,13 @@ function formatMentions(content: string) { Tiết lộ - +
+ +
{{ (replyContent[reply.id] || '').length }} / 1000 @@ -124,11 +131,12 @@ function formatMentions(content: string) {
- + diff --git a/app/components/CommentSection.vue b/app/components/CommentSection.vue index 2dff61d..54ab0a5 100644 --- a/app/components/CommentSection.vue +++ b/app/components/CommentSection.vue @@ -14,8 +14,30 @@ const commentContent = ref('') const isCommentSubmitting = ref(false) const hasDraft = ref(false) const isContentHidden = ref(false) +const isGifPickerOpen = ref(false) +const gifPickerTarget = ref<'main' | number>('main') +const gifPickerRef = ref(null) let draftAutoSaveTimer: ReturnType | undefined +function insertGif(url: string) { + const gifTag = `![GIF](${url})` + if (gifPickerTarget.value === 'main') { + if (commentContent.value) { + commentContent.value += '\n' + gifTag + } else { + commentContent.value = gifTag + } + } else { + const currentContent = replyContent.value[gifPickerTarget.value] || '' + if (currentContent) { + replyContent.value[gifPickerTarget.value] = currentContent + '\n' + gifTag + } else { + replyContent.value[gifPickerTarget.value] = gifTag + } + } + isGifPickerOpen.value = false +} + const comments = ref([]) const isCommentsLoading = ref(false) const replyContent = ref>({}) @@ -330,7 +352,24 @@ function timeAgo(dateStr: string): string { } function formatMentions(content: string) { - return content.replace(/@(\S+)/g, '@$1') + let html = content.replace(/@(\S+)/g, '@$1') + html = html.replace(/!\[GIF\]\((https?:\/\/[^\s)]+)\)/g, 'GIF') + return html +} + +function openGifPicker(target: 'main' | number = 'main') { + gifPickerTarget.value = target + isGifPickerOpen.value = !isGifPickerOpen.value + if (isGifPickerOpen.value) { + nextTick(() => { + const selector = target === 'main' ? '.comment-gif-btn' : `.reply-gif-btn-${target}` + document.querySelectorAll('.gif-trigger-active').forEach(el => el.classList.remove('gif-trigger-active')) + document.querySelector(selector)?.classList.add('gif-trigger-active') + gifPickerRef.value?.updatePosition(selector) + }) + } else { + document.querySelectorAll('.gif-trigger-active').forEach(el => el.classList.remove('gif-trigger-active')) + } } onMounted(() => { @@ -356,7 +395,7 @@ watch(() => props.slug, () => {

Đăng nhập để bình luận về phim này.

-
+
@@ -381,9 +420,11 @@ watch(() => props.slug, () => { Không tiết lộ
- +
+ +
{{ commentContent.length }} / 1000 @@ -500,10 +541,13 @@ watch(() => props.slug, () => { Tiết lộ
- +
+ +
{{ (replyContent[comment.id] || '').length }} / 1000 @@ -532,7 +576,8 @@ watch(() => props.slug, () => {
@@ -563,6 +608,10 @@ watch(() => props.slug, () => {

Chưa có bình luận nào.

+ + + + diff --git a/app/components/GifPicker.vue b/app/components/GifPicker.vue new file mode 100644 index 0000000..fcae1b7 --- /dev/null +++ b/app/components/GifPicker.vue @@ -0,0 +1,166 @@ + + + + + diff --git a/image-1.png b/image-1.png deleted file mode 100644 index 5106b6a..0000000 Binary files a/image-1.png and /dev/null differ diff --git a/image.png b/image.png deleted file mode 100644 index 0b797f5..0000000 Binary files a/image.png and /dev/null differ diff --git a/nuxt.config.ts b/nuxt.config.ts index e69a6c1..f24762e 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -4,6 +4,11 @@ import tailwindcss from '@tailwindcss/vite' export default defineNuxtConfig({ compatibilityDate: '2025-07-15', devtools: { enabled: true }, + runtimeConfig: { + public: { + giphyApiKey: process.env.GIPHY_API_KEY, + }, + }, app: { head: { titleTemplate: (titleChunk) => titleChunk ? `${titleChunk}` : 'CineK - Xem phim Hàn Quốc online',