diff --git a/src/app/init/project.tsx b/src/app/init/project.tsx index 1084f43..9705ac5 100644 --- a/src/app/init/project.tsx +++ b/src/app/init/project.tsx @@ -4,6 +4,7 @@ import {useQuery} from '@tanstack/react-query'; import {CheckCircle2, Loader2, XCircle} from 'lucide-react'; import {toast} from 'sonner'; import {projectCreate, projectInfo, workspaceList} from '@/client'; +import {isAxiosError} from 'axios'; import {Button} from '@/components/ui/button'; import {Input} from '@/components/ui/input'; import {Label} from '@/components/ui/label'; @@ -59,11 +60,12 @@ export function InitProject() { try { const lower = name.trim().toLowerCase(); await projectInfo({path: {project_name: lower}}); + // 200 OK → 项目存在 setNameAvailable(false); setAvailabilityMessage('Project name already exists'); } catch (err: unknown) { - const status = (err as any)?.response?.status; - if (status === 404) { + // @hey-api/openapi-ts 默认 throwOnError=false,错误作为 AxiosError 返回 + if (isAxiosError(err) && err.response?.status === 404) { setNameAvailable(true); setAvailabilityMessage('Project name is available'); } else {