/**
 * 获取产品列表
 * 支持按分类和用途筛选
 */
export default defineEventHandler(async (event) => {
  // 模拟延迟
  await new Promise((resolve) => setTimeout(resolve, 500));

  // 获取查询参数
  const query = getQuery(event);
  const category = query.category as string;
  const usage = query.usage as string;

  // 模拟数据
  const products = [
    {
      id: 1,
      name: "Hanye Q60-256GST3",
      category: "2.5-inch SSD",
      usage: "PC高速化・アップグレード",
      capacities: ["256GB", "512GB", "1TB", "2TB"],
      image: "https://picsum.photos/400/400?random=1",
      description: "高性能2.5インチSSD、読み書き速度が速く、信頼性が高い",
    },
    {
      id: 2,
      name: "Hanye Q60-512GST3",
      category: "2.5-inch SSD",
      usage: "PC高速化・アップグレード",
      capacities: ["512GB", "1TB", "2TB"],
      image: "https://picsum.photos/400/400?random=2",
      description: "大容量2.5インチSSD、高速転送と安定した性能",
    },
    {
      id: 3,
      name: "Hanye Q60-1TBST3",
      category: "2.5-inch SSD",
      usage: "外付けストレージ化",
      capacities: ["1TB", "2TB"],
      image: "https://picsum.photos/400/400?random=3",
      description: "大容量ストレージソリューション、データバックアップに最適",
    },
    {
      id: 4,
      name: "Hanye Q60-2TBST3",
      category: "2.5-inch SSD",
      usage: "外付けストレージ化",
      capacities: ["2TB"],
      image: "https://picsum.photos/400/400?random=4",
      description: "超大容量SSD、プロフェッショナル向けストレージソリューション",
    },
  ];

  // 筛选逻辑
  let filteredProducts = [...products];
  if (category) {
    filteredProducts = filteredProducts.filter((p) => p.category === category);
  }
  if (usage) {
    filteredProducts = filteredProducts.filter((p) => p.usage === usage);
  }

  return {
    products: filteredProducts,
    categories: Array.from(new Set(products.map((p) => p.category))),
    usages: Array.from(new Set(products.map((p) => p.usage))),
  };
}); 