- 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.
30 lines
585 B
TypeScript
30 lines
585 B
TypeScript
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();
|
|
|