refactor(Post, PostMapper, PostRepository, CreatePostScreen, HomeScreen): update communityId to channelId for improved clarity
- Renamed communityId to channelId across Post entity, PostMapper, and PostRepository for consistency and clarity. - Updated CreatePostScreen to include channel selection functionality, enhancing user experience when creating posts. - Adjusted HomeScreen to support filtering posts by channel, improving content organization. - Refactored related interfaces and services to align with the new channelId terminology, ensuring a cohesive codebase.
This commit is contained in:
29
src/services/channelService.ts
Normal file
29
src/services/channelService.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { api } from './api';
|
||||
|
||||
export interface ChannelItem {
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
description?: string;
|
||||
sort_order: number;
|
||||
is_active: boolean;
|
||||
}
|
||||
|
||||
interface ChannelListResponse {
|
||||
list: ChannelItem[];
|
||||
}
|
||||
|
||||
class ChannelService {
|
||||
async list(): Promise<ChannelItem[]> {
|
||||
try {
|
||||
const res = await api.get<ChannelListResponse>('/channels');
|
||||
return res.data?.list || [];
|
||||
} catch (error) {
|
||||
console.error('[channelService] 获取频道失败:', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const channelService = new ChannelService();
|
||||
|
||||
Reference in New Issue
Block a user