diff --git a/src/app/chat/components/fullscreen-image-viewer.module.css b/src/app/chat/components/fullscreen-image-viewer.module.css
index 08aa5c9a..1fd61097 100644
--- a/src/app/chat/components/fullscreen-image-viewer.module.css
+++ b/src/app/chat/components/fullscreen-image-viewer.module.css
@@ -30,6 +30,13 @@
transform: scale(1.08);
}
+.nativePaywallImage {
+ position: absolute;
+ inset: 0;
+ width: 100%;
+ height: 100%;
+}
+
.paywallScrim {
position: absolute;
inset: 0;
diff --git a/src/app/chat/components/fullscreen-image-viewer.tsx b/src/app/chat/components/fullscreen-image-viewer.tsx
index 3b4d8088..e0b861de 100644
--- a/src/app/chat/components/fullscreen-image-viewer.tsx
+++ b/src/app/chat/components/fullscreen-image-viewer.tsx
@@ -1,4 +1,5 @@
"use client";
+/* eslint-disable @next/next/no-img-element */
/**
* FullscreenImageViewer 全屏图片查看器
*
@@ -13,9 +14,11 @@ import { ChevronLeft } from "lucide-react";
import Image from "next/image";
import { useEffect } from "react";
+import { useCachedChatMediaUrl } from "../hooks/use-cached-chat-media-url";
import styles from "./fullscreen-image-viewer.module.css";
export interface FullscreenImageViewerProps {
+ messageId?: string;
imageUrl: string;
imagePaywalled?: boolean;
onUnlockImagePaywall?: () => void;
@@ -23,11 +26,18 @@ export interface FullscreenImageViewerProps {
}
export function FullscreenImageViewer({
+ messageId,
imageUrl,
imagePaywalled = false,
onUnlockImagePaywall,
onClose,
}: FullscreenImageViewerProps) {
+ const { mediaUrl } = useCachedChatMediaUrl({
+ messageId,
+ remoteUrl: imageUrl,
+ kind: "image",
+ });
+
useEffect(() => {
const handleKey = (e: KeyboardEvent) => {
if (e.key === "Escape") onClose();
@@ -36,9 +46,13 @@ export function FullscreenImageViewer({
return () => document.removeEventListener("keydown", handleKey);
}, [onClose]);
- const src = imageUrl.startsWith("data:") || imageUrl.startsWith("http")
- ? imageUrl
- : `data:image/png;base64,${imageUrl}`;
+ const sourceUrl = mediaUrl || imageUrl;
+ const src = sourceUrl.startsWith("data:") ||
+ sourceUrl.startsWith("http") ||
+ sourceUrl.startsWith("blob:")
+ ? sourceUrl
+ : `data:image/png;base64,${sourceUrl}`;
+ const shouldUseNativeImage = isBrowserLocalImageSrc(src);
if (imagePaywalled) {
return (
@@ -47,13 +61,21 @@ export function FullscreenImageViewer({
role="dialog"
aria-label="Locked fullscreen image"
>
-
+ {shouldUseNativeImage ? (
+
+ ) : (
+
+ )}