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();

