feat(chat): add private message unlock flow

This commit is contained in:
2026-06-23 13:21:57 +08:00
parent c9d75b6fe6
commit ebd44c4980
20 changed files with 455 additions and 29 deletions
+33 -3
View File
@@ -10,19 +10,35 @@
* - 两者都有:图片在上,文字在下
*/
import { ImageBubble } from "./image-bubble";
import { PrivateMessageCard } from "./private-message-card";
import { TextBubble } from "./text-bubble";
export interface MessageContentProps {
messageId?: string;
content: string;
imageUrl?: string | null;
isFromAI: boolean;
privateLocked?: boolean | null;
privateHint?: string | null;
isUnlockingPrivate?: boolean;
onUnlockPrivateMessage?: (messageId: string) => void;
}
const IMAGE_PLACEHOLDER = "[图片]";
export function MessageContent({ content, imageUrl, isFromAI }: MessageContentProps) {
export function MessageContent({
messageId,
content,
imageUrl,
isFromAI,
privateLocked,
privateHint,
isUnlockingPrivate = false,
onUnlockPrivateMessage,
}: MessageContentProps) {
const hasImage = imageUrl != null && imageUrl.length > 0;
const hasText = content.length > 0 && content !== IMAGE_PLACEHOLDER;
const isLockedPrivateMessage = privateLocked === true;
return (
<div
@@ -37,8 +53,22 @@ export function MessageContent({ content, imageUrl, isFromAI }: MessageContentPr
gap: 8,
}}
>
{hasImage && imageUrl && <ImageBubble imageUrl={imageUrl} />}
{hasText && <TextBubble content={content} isFromAI={isFromAI} />}
{isLockedPrivateMessage ? (
<PrivateMessageCard
hint={privateHint}
isUnlocking={isUnlockingPrivate}
onUnlock={
messageId
? () => onUnlockPrivateMessage?.(messageId)
: undefined
}
/>
) : (
<>
{hasImage && imageUrl && <ImageBubble imageUrl={imageUrl} />}
{hasText && <TextBubble content={content} isFromAI={isFromAI} />}
</>
)}
</div>
);
}