refactor(PostCard, ImageGrid, SmartImage): enhance post editing display and image handling
- Introduced a new method to determine the last edited time for posts, prioritizing content_edited_at for better accuracy in display. - Updated PostCard and PostDetailScreen components to utilize the new editing display logic. - Enhanced ImageGrid and SmartImage components to support additional preview URLs and improve image loading behavior, including lazy loading optimizations for web. - Modified Post and PostDTO interfaces to include contentEditedAt for better tracking of post edits.
This commit is contained in:
@@ -27,7 +27,12 @@ export class PostMapper {
|
||||
communityId: response.community_id,
|
||||
tags: [],
|
||||
createdAt: new Date(response.created_at || Date.now()),
|
||||
updatedAt: new Date(response.updated_at || Date.now()),
|
||||
// 空字符串/缺省时用 created_at,避免误用 Date.now() 导致全部显示「刚修改」
|
||||
updatedAt: new Date(
|
||||
response.updated_at ||
|
||||
response.created_at ||
|
||||
Date.now()
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ interface PostApiResponse {
|
||||
tags?: string[];
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
content_edited_at?: string;
|
||||
author?: {
|
||||
id: number;
|
||||
username: string;
|
||||
@@ -122,6 +123,7 @@ export class PostRepository implements IPostRepository {
|
||||
tags: model.tags || [],
|
||||
createdAt: model.createdAt.toISOString(),
|
||||
updatedAt: model.updatedAt.toISOString(),
|
||||
contentEditedAt: response.content_edited_at,
|
||||
|
||||
// snake_case 字段(向后兼容)
|
||||
likes_count: model.likeCount,
|
||||
@@ -135,6 +137,7 @@ export class PostRepository implements IPostRepository {
|
||||
user_id: model.authorId,
|
||||
created_at: model.createdAt.toISOString(),
|
||||
updated_at: model.updatedAt.toISOString(),
|
||||
content_edited_at: response.content_edited_at,
|
||||
community_id: model.communityId,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user