From e349e0cfe38c1971c08f96848323b1dadc23a40d Mon Sep 17 00:00:00 2001 From: 2977094657 <2977094657@qq.com> Date: Mon, 9 Mar 2026 20:31:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A1=8C=E9=9D=A2=E7=AB=AF?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=9F=A5=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/pages/chat/[[username]].vue | 96 +++++++++++++++----- frontend/pages/sns.vue | 127 ++++++++++++++++++++++++--- 2 files changed, 192 insertions(+), 31 deletions(-) diff --git a/frontend/pages/chat/[[username]].vue b/frontend/pages/chat/[[username]].vue index d740d74..56cee92 100644 --- a/frontend/pages/chat/[[username]].vue +++ b/frontend/pages/chat/[[username]].vue @@ -589,17 +589,16 @@ :class="message.isSent ? 'bg-[#95EC69] text-black bubble-tail-r' : 'bg-white text-gray-800 bubble-tail-l'"> {{ message.content }} -
-
+
@@ -1388,6 +1387,40 @@
+ +
+
+ +
+ {{ previewVideoError }} +
+
+ +
+
{{ rec.content || '[视频]' }}
-
-
+
{{ rec.content || '[视频]' }}
-
-
+
@@ -4070,15 +4101,42 @@ const scrollToMessageId = async (id) => { // 图片预览状态 const previewImageUrl = ref(null) +const previewVideoUrl = ref(null) +const previewVideoPosterUrl = ref('') +const previewVideoError = ref('') const openImagePreview = (url) => { + if (!process.client) return previewImageUrl.value = url document.body.style.overflow = 'hidden' } const closeImagePreview = () => { + if (!process.client) return previewImageUrl.value = null - document.body.style.overflow = '' + if (!previewVideoUrl.value) document.body.style.overflow = '' +} + +const openVideoPreview = (url, poster) => { + if (!process.client) return + const u = String(url || '').trim() + if (!u) return + previewVideoError.value = '' + previewVideoPosterUrl.value = String(poster || '').trim() + previewVideoUrl.value = u + document.body.style.overflow = 'hidden' +} + +const closeVideoPreview = () => { + if (!process.client) return + previewVideoUrl.value = null + previewVideoPosterUrl.value = '' + previewVideoError.value = '' + if (!previewImageUrl.value) document.body.style.overflow = '' +} + +const onPreviewVideoError = () => { + previewVideoError.value = '视频加载失败。' } const voiceRefs = ref({}) @@ -7047,9 +7105,7 @@ const openChatHistoryQuote = (rec) => { if (!url) return if (kind === 'video') { - try { - window.open(url, '_blank', 'noreferrer') - } catch {} + openVideoPreview(url, q?.thumbUrl) return } @@ -7392,6 +7448,7 @@ const onGlobalKeyDown = (e) => { if (key === 'Escape') { if (contextMenu.value.visible) closeContextMenu() if (previewImageUrl.value) closeImagePreview() + if (previewVideoUrl.value) closeVideoPreview() if (Array.isArray(floatingWindows.value) && floatingWindows.value.length) closeTopFloatingWindow() if (chatHistoryModalVisible.value) closeChatHistoryModal() if (contactProfileCardOpen.value) { @@ -9311,4 +9368,3 @@ const LinkCard = defineComponent({ } } - diff --git a/frontend/pages/sns.vue b/frontend/pages/sns.vue index 3c5d121..9258c61 100644 --- a/frontend/pages/sns.vue +++ b/frontend/pages/sns.vue @@ -638,7 +638,19 @@ >
+ 预览 +
+ {{ previewVideoError }} +
+