feat(content): add rich content rendering with @mentions and vote segments
- Add PostContentRenderer component for rendering posts/comments with segments - Add PostMentionInput component for @mention support in post/comment creation - Add VoteSegmentData and vote segment type for unified post creation API - Update post and comment services to support segments in API requests - Fix auth service to clear tokens before login/register - Improve database initialization with proper close/retry logic - Add verification check before allowing post creation - Add metro web shims for react-native-webrtc full package and requireNativeComponent - Update build config with git hash based version numbers
This commit is contained in:
@@ -68,6 +68,7 @@ export interface PostDTO {
|
||||
user_id: string;
|
||||
title: string;
|
||||
content: string;
|
||||
segments?: MessageSegment[];
|
||||
images: PostImageDTO[];
|
||||
status?: string;
|
||||
likes_count: number;
|
||||
@@ -111,6 +112,7 @@ export interface CommentDTO {
|
||||
parent_id: string | null;
|
||||
root_id: string | null;
|
||||
content: string;
|
||||
segments?: MessageSegment[];
|
||||
images: CommentImageDTO[];
|
||||
likes_count: number;
|
||||
replies_count: number;
|
||||
@@ -148,7 +150,7 @@ export type MessageStatus = 'normal' | 'recalled' | 'deleted';
|
||||
// ==================== Message Segment Types ====================
|
||||
|
||||
// Segment类型
|
||||
export type SegmentType = 'text' | 'image' | 'voice' | 'video' | 'file' | 'at' | 'reply' | 'face' | 'link';
|
||||
export type SegmentType = 'text' | 'image' | 'voice' | 'video' | 'file' | 'at' | 'reply' | 'face' | 'link' | 'vote';
|
||||
|
||||
// 文本Segment数据
|
||||
export interface TextSegmentData {
|
||||
@@ -217,6 +219,19 @@ export interface LinkSegmentData {
|
||||
image?: string;
|
||||
}
|
||||
|
||||
// 投票选项数据
|
||||
export interface VoteOptionData {
|
||||
id: string;
|
||||
content: string;
|
||||
}
|
||||
|
||||
// 投票Segment数据
|
||||
export interface VoteSegmentData {
|
||||
options: VoteOptionData[];
|
||||
max_choices?: number;
|
||||
is_multi_choice?: boolean;
|
||||
}
|
||||
|
||||
// MessageSegment 联合类型 - 使用 discriminated union
|
||||
export type MessageSegment =
|
||||
| { type: 'text'; data: TextSegmentData }
|
||||
@@ -227,7 +242,8 @@ export type MessageSegment =
|
||||
| { type: 'at'; data: AtSegmentData }
|
||||
| { type: 'reply'; data: ReplySegmentData }
|
||||
| { type: 'face'; data: FaceSegmentData }
|
||||
| { type: 'link'; data: LinkSegmentData };
|
||||
| { type: 'link'; data: LinkSegmentData }
|
||||
| { type: 'vote'; data: VoteSegmentData };
|
||||
|
||||
// 消息响应
|
||||
export interface MessageResponse {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// ============================================
|
||||
// ============================================
|
||||
// WithYou - Core Type Definitions
|
||||
// 使用后端DTO类型,保持snake_case命名规范
|
||||
// ============================================
|
||||
@@ -37,43 +37,14 @@ import type {
|
||||
VoiceSegmentData,
|
||||
VideoSegmentData,
|
||||
FileSegmentData,
|
||||
AtSegmentData,
|
||||
AtSegmentData,
|
||||
ReplySegmentData,
|
||||
FaceSegmentData,
|
||||
LinkSegmentData,
|
||||
VoteSegmentData,
|
||||
VoteOptionData,
|
||||
} from './dto';
|
||||
|
||||
// 重新导出新的聊天系统类型
|
||||
export type {
|
||||
ConversationType,
|
||||
MessageContentType,
|
||||
MessageStatus,
|
||||
MessageResponse,
|
||||
ConversationResponse,
|
||||
ConversationParticipantResponse,
|
||||
ConversationDetailResponse,
|
||||
CreateConversationRequest,
|
||||
SendMessageRequest,
|
||||
MarkReadRequest,
|
||||
UnreadCountResponse,
|
||||
ConversationUnreadCountResponse,
|
||||
ConversationListResponse,
|
||||
MessageListResponse,
|
||||
MessageSyncResponse,
|
||||
// Segment 类型
|
||||
SegmentType,
|
||||
MessageSegment,
|
||||
TextSegmentData,
|
||||
ImageSegmentData,
|
||||
VoiceSegmentData,
|
||||
VideoSegmentData,
|
||||
FileSegmentData,
|
||||
AtSegmentData,
|
||||
ReplySegmentData,
|
||||
FaceSegmentData,
|
||||
LinkSegmentData,
|
||||
};
|
||||
|
||||
// ============================================
|
||||
// User Types
|
||||
// ============================================
|
||||
@@ -101,8 +72,9 @@ export type { VoteOptionDTO as VoteOption, VoteResultDTO as VoteResult, CreateVo
|
||||
|
||||
export interface CreatePostInput {
|
||||
title: string;
|
||||
content: string;
|
||||
images?: string[]; // 本地图片路径或 base64
|
||||
content?: string;
|
||||
segments?: MessageSegment[];
|
||||
images?: string[];
|
||||
channel_id?: string;
|
||||
}
|
||||
|
||||
@@ -122,6 +94,7 @@ export interface Comment {
|
||||
parent_id: string | null;
|
||||
root_id?: string | null;
|
||||
content: string;
|
||||
segments?: MessageSegment[];
|
||||
images?: CommentImage[];
|
||||
likes_count: number;
|
||||
replies_count: number;
|
||||
|
||||
Reference in New Issue
Block a user