import { StyleProp, ViewStyle } from 'react-native'; import type { SenderType } from '../DbChatAvatar/types'; import type { MessageType, MessageDirection, MessageStatus } from '../DbChatBubble/types'; /** 内容块类型 - 用于富文本消息的分段 */ export type ContentBlockType = 'text' | 'code' | 'markdown' | 'conversation' | 'question-list' | 'table'; /** 代码块 */ export interface CodeBlock { type: 'code'; language?: string; code: string; } /** Markdown 块 */ export interface MarkdownBlock { type: 'markdown'; content: string; } /** 会话块 - 多轮对话 */ export interface ConversationBlock { type: 'conversation'; items: Array<{ role: 'user' | 'assistant'; content: string; }>; } /** 问题列表块 */ export interface QuestionListBlock { type: 'question-list'; items: Array<{ id: string; question: string; answer?: string; }>; } /** 表格块 */ export interface TableBlock { type: 'table'; headers: string[]; rows: string[][]; } /** 文本块 */ export interface TextBlock { type: 'text'; content: string; } /** 内容块联合类型 */ export type ContentBlock = TextBlock | CodeBlock | MarkdownBlock | ConversationBlock | QuestionListBlock | TableBlock; /** 消息数据结构 */ export interface ChatMessageData { /** 消息 ID */ id: string; /** 消息类型 */ type: MessageType; /** 消息方向 */ direction: MessageDirection; /** 发送者类型 */ senderType: SenderType; /** 消息内容(文本或 ReactNode) */ content: string; /** 结构化内容块(可选,用于富文本消息) */ contentBlocks?: ContentBlock[]; /** 发送者名称 */ senderName?: string; /** 发送者头像 URL */ senderAvatar?: string; /** 时间戳 */ timestamp: number; /** 消息状态 */ status: MessageStatus; /** 是否已读 */ isRead?: boolean; /** AI 流式输出中 */ isStreaming?: boolean; /** AI 加载中(等待服务端响应) */ isLoading?: boolean; } /** 完整消息组件 Props */ export interface DbChatMessageProps { /** 消息数据 */ message: ChatMessageData; /** 是否显示头像(对方消息) */ showAvatar?: boolean; /** 是否显示我的头像(右侧/自己发送的消息) */ showMyAvatar?: boolean; /** 是否显示时间 */ showTime?: boolean; /** 是否显示状态(已读/未读) */ showStatus?: boolean; /** 是否显示发送者名称 */ showSenderName?: boolean; /** 重试回调 */ onRetry?: (id: string) => void; /** 长按回调 */ onLongPress?: (message: ChatMessageData) => void; /** 点击头像回调 */ onAvatarPress?: (message: ChatMessageData) => void; /** 自定义样式 */ style?: StyleProp; } export type { SenderType, MessageType, MessageDirection, MessageStatus };