From d42b72b650b13473961bfbaa9ed614742a7140fb Mon Sep 17 00:00:00 2001 From: tech Date: Wed, 4 Mar 2026 21:35:43 +0800 Subject: [PATCH] feat: update SearchForm to use project display names Add Project interface with name and displayName fields to support project aliases. Update SWR hook to type projects as Project[]. Display project.displayName in dropdown while using project.name as the option value for API compatibility. Co-Authored-By: Claude Sonnet 4.6 --- app/download/SearchForm.tsx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/download/SearchForm.tsx b/app/download/SearchForm.tsx index a365e92..d59cf9c 100644 --- a/app/download/SearchForm.tsx +++ b/app/download/SearchForm.tsx @@ -1,4 +1,3 @@ -// app/download/SearchForm.tsx 'use client'; import { useState } from 'react'; @@ -13,6 +12,11 @@ const fetcher = async (url: string) => { return res.json(); }; +interface Project { + name: string; + displayName: string; +} + interface SearchFormProps { onSearch: (project: string, version: string, commitId: string) => void; } @@ -23,13 +27,13 @@ export default function SearchForm({ onSearch }: SearchFormProps) { const [commitId, setCommitId] = useState(''); // 获取项目列表 - const { data: projects, isLoading: loadingProjects } = useSWR( + const { data: projects, isLoading: loadingProjects } = useSWR( '/api/projects', fetcher ); // 获取版本列表 - const { data: versions, isLoading: loadingVersions } = useSWR( + const { data: versions, isLoading: loadingVersions } = useSWR( selectedProject ? `/api/versions?project=${selectedProject}` : null, fetcher ); @@ -61,9 +65,9 @@ export default function SearchForm({ onSearch }: SearchFormProps) { {loadingProjects ? ( ) : ( - projects?.map((project: string) => ( - )) )} @@ -86,7 +90,7 @@ export default function SearchForm({ onSearch }: SearchFormProps) { {loadingVersions ? ( ) : ( - versions?.map((version: string) => ( + versions?.map((version) => (