dev #5
@@ -53,10 +53,13 @@ interface PostApiResponse {
|
||||
* API帖子列表响应类型
|
||||
*/
|
||||
interface PostsListApiResponse {
|
||||
posts: PostApiResponse[];
|
||||
has_more: boolean;
|
||||
list: PostApiResponse[];
|
||||
has_more?: boolean;
|
||||
next_cursor?: string;
|
||||
total?: number;
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
total_pages?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,7 +245,7 @@ export class PostRepository implements IPostRepository {
|
||||
|
||||
const response = await this.api.get<PostsListApiResponse>('/posts', queryParams);
|
||||
|
||||
const posts = response.posts.map(p => this.mapToPost(p));
|
||||
const posts = (response.list || []).map(p => this.mapToPost(p));
|
||||
|
||||
// 缓存帖子
|
||||
posts.forEach(post => {
|
||||
@@ -252,7 +255,7 @@ export class PostRepository implements IPostRepository {
|
||||
|
||||
return {
|
||||
posts,
|
||||
hasMore: response.has_more,
|
||||
hasMore: response.has_more ?? false,
|
||||
nextCursor: response.next_cursor,
|
||||
total: response.total,
|
||||
};
|
||||
@@ -315,7 +318,7 @@ export class PostRepository implements IPostRepository {
|
||||
|
||||
const response = await this.api.get<PostsListApiResponse>(`/users/${userId}/posts`, queryParams);
|
||||
|
||||
const posts = response.posts.map(p => this.mapToPost(p));
|
||||
const posts = (response.list || []).map(p => this.mapToPost(p));
|
||||
|
||||
// 缓存帖子
|
||||
posts.forEach(post => {
|
||||
@@ -325,7 +328,7 @@ export class PostRepository implements IPostRepository {
|
||||
|
||||
return {
|
||||
posts,
|
||||
hasMore: response.has_more,
|
||||
hasMore: response.has_more ?? false,
|
||||
nextCursor: response.next_cursor,
|
||||
total: response.total,
|
||||
};
|
||||
@@ -350,7 +353,7 @@ export class PostRepository implements IPostRepository {
|
||||
|
||||
const response = await this.api.get<PostsListApiResponse>('/posts/search', queryParams);
|
||||
|
||||
const posts = response.posts.map(p => this.mapToPost(p));
|
||||
const posts = (response.list || []).map(p => this.mapToPost(p));
|
||||
|
||||
// 缓存帖子
|
||||
posts.forEach(post => {
|
||||
@@ -360,7 +363,7 @@ export class PostRepository implements IPostRepository {
|
||||
|
||||
return {
|
||||
posts,
|
||||
hasMore: response.has_more,
|
||||
hasMore: response.has_more ?? false,
|
||||
nextCursor: response.next_cursor,
|
||||
total: response.total,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user