All files / constants petBreeds.ts

100% Statements 14/14
100% Branches 5/5
100% Functions 4/4
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131                                  3x                                                   3x                                                           3x                               3x                                   9x   2x   2x   2x   1x   2x                   4x 54x    
/**
 * 宠物品种数据配置
 * 根据宠物类型提供对应的品种列表
 */
 
/** 宠物类型 */
export type PetSpecies = 'cat' | 'dog' | 'bird' | 'other';
 
/** 品种配置接口 */
interface BreedConfig {
  label: string;
  popular?: boolean; // 是否为热门品种
}
 
/**
 * 猫咪品种列表
 */
export const CAT_BREEDS: BreedConfig[] = [
  { label: '英国短毛猫', popular: true },
  { label: '美国短毛猫', popular: true },
  { label: '布偶猫', popular: true },
  { label: '暹罗猫', popular: true },
  { label: '波斯猫', popular: true },
  { label: '缅因猫', popular: true },
  { label: '苏格兰折耳猫' },
  { label: '加菲猫(异国短毛猫)' },
  { label: '金渐层' },
  { label: '银渐层' },
  { label: '橘猫' },
  { label: '狸花猫' },
  { label: '三花猫' },
  { label: '奶牛猫' },
  { label: '俄罗斯蓝猫' },
  { label: '孟加拉豹猫' },
  { label: '无毛猫(斯芬克斯)' },
  { label: '挪威森林猫' },
  { label: '土耳其安哥拉猫' },
  { label: '其他' },
];
 
/**
 * 狗狗品种列表
 */
export const DOG_BREEDS: BreedConfig[] = [
  { label: '金毛寻回犬', popular: true },
  { label: '拉布拉多', popular: true },
  { label: '哈士奇', popular: true },
  { label: '柯基', popular: true },
  { label: '泰迪(贵宾犬)', popular: true },
  { label: '萨摩耶', popular: true },
  { label: '边境牧羊犬' },
  { label: '德国牧羊犬' },
  { label: '柴犬' },
  { label: '秋田犬' },
  { label: '比熊' },
  { label: '博美' },
  { label: '吉娃娃' },
  { label: '雪纳瑞' },
  { label: '法国斗牛犬' },
  { label: '英国斗牛犬' },
  { label: '阿拉斯加' },
  { label: '松狮' },
  { label: '巴哥' },
  { label: '约克夏' },
  { label: '杜宾犬' },
  { label: '罗威纳' },
  { label: '中华田园犬' },
  { label: '其他' },
];
 
/**
 * 鸟类品种列表
 */
export const BIRD_BREEDS: BreedConfig[] = [
  { label: '虎皮鹦鹉', popular: true },
  { label: '玄凤鹦鹉', popular: true },
  { label: '牡丹鹦鹉', popular: true },
  { label: '文鸟' },
  { label: '金丝雀' },
  { label: '八哥' },
  { label: '画眉' },
  { label: '相思鸟' },
  { label: '珍珠鸟' },
  { label: '其他' },
];
 
/**
 * 其他宠物品种列表
 */
export const OTHER_BREEDS: BreedConfig[] = [
  { label: '仓鼠' },
  { label: '兔子' },
  { label: '龙猫' },
  { label: '荷兰猪(豚鼠)' },
  { label: '刺猬' },
  { label: '乌龟' },
  { label: '金鱼' },
  { label: '热带鱼' },
  { label: '其他' },
];
 
/**
 * 根据宠物类型获取品种列表
 * @param species 宠物类型
 * @returns 品种列表
 */
export function getBreedsBySpecies(species: PetSpecies): BreedConfig[] {
  switch (species) {
    case 'cat':
      return CAT_BREEDS;
    case 'dog':
      return DOG_BREEDS;
    case 'bird':
      return BIRD_BREEDS;
    case 'other':
      return OTHER_BREEDS;
    default:
      return [];
  }
}
 
/**
 * 获取热门品种列表
 * @param species 宠物类型
 * @returns 热门品种列表
 */
export function getPopularBreeds(species: PetSpecies): string[] {
  const breeds = getBreedsBySpecies(species);
  return breeds.filter((b) => b.popular).map((b) => b.label);
}