@@ -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 }}
+
+