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