diff --git a/src/components/chat/ChatMessageElementImage.vue b/src/components/chat/ChatMessageElementImage.vue index 03c8ef90..8942db13 100644 --- a/src/components/chat/ChatMessageElementImage.vue +++ b/src/components/chat/ChatMessageElementImage.vue @@ -11,7 +11,7 @@ async function previewImage(event: Event) { const currentIndex = Array.from(gallery).indexOf(event.target as HTMLImageElement) const urls = Array.from(gallery).map((img) => img.src) const window = await createPreviewWindow('/preview/image', '图像预览', naturalWidth, naturalHeight) - window.listen('preview-window-created', () => { + window.once('preview-window-created', () => { window.emit('set-preview-content', { urls, currentIndex }) }) } diff --git a/src/views/preview/image.vue b/src/views/preview/image.vue index f442fc66..fad90498 100644 --- a/src/views/preview/image.vue +++ b/src/views/preview/image.vue @@ -11,14 +11,14 @@ interface PreviewContent { currentIndex: number } -let previewContent: PreviewContent = $ref({ +let previewContent = $ref({ urls: [], currentIndex: 0, }) const currentImage = $computed(() => previewContent.urls[previewContent.currentIndex]) -currentWindow.listen('set-preview-content', (e) => { +currentWindow.once('set-preview-content', (e) => { previewContent = e.payload })