From f876a65c6b4cb885fe6dc75beb565f5add4358af Mon Sep 17 00:00:00 2001 From: abearxiong Date: Tue, 10 Feb 2026 00:18:57 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E4=BB=93=E5=BA=93=E5=AF=B9=E8=AF=9D=E6=A1=86=E5=92=8C=E5=81=9C?= =?UTF-8?q?=E6=AD=A2=E5=B7=A5=E4=BD=9C=E5=8C=BA=E5=8A=9F=E8=83=BD=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=93=E5=BA=93=E5=88=97=E8=A1=A8=E7=95=8C?= =?UTF-8?q?=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/repo/modules/CreateRepoDialog.tsx | 128 ++++++++++++++++++ .../repo/modules/WorkspaceDetailDialog.tsx | 12 +- src/app/repo/page.tsx | 24 +++- src/app/repo/store/index.ts | 50 ++++++- 4 files changed, 207 insertions(+), 7 deletions(-) create mode 100644 src/app/repo/modules/CreateRepoDialog.tsx diff --git a/src/app/repo/modules/CreateRepoDialog.tsx b/src/app/repo/modules/CreateRepoDialog.tsx new file mode 100644 index 0000000..621658f --- /dev/null +++ b/src/app/repo/modules/CreateRepoDialog.tsx @@ -0,0 +1,128 @@ +import { useEffect, useState } from 'react' +import { useForm } from 'react-hook-form' +import { + Dialog, + DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, + DialogTitle, +} from '@/components/ui/dialog' +import { Button } from '@/components/ui/button' +import { Input } from '@/components/ui/input' +import { Label } from '@/components/ui/label' +import { Textarea } from '@/components/ui/textarea' +import { useRepoStore } from '../store' + +interface CreateRepoDialogProps { + open: boolean + onOpenChange: (open: boolean) => void +} + +interface FormData { + path: string + license: string + description: string + visibility: string +} + +export function CreateRepoDialog({ open, onOpenChange }: CreateRepoDialogProps) { + const { createRepo, getList } = useRepoStore() + const { register, handleSubmit, reset } = useForm() + const [isSubmitting, setIsSubmitting] = useState(false) + + useEffect(() => { + if (open) { + // 重置表单 + reset({ + path: '', + license: '', + description: '', + visibility: 'public' + }) + } + }, [open, reset]) + + const onSubmit = async (data: FormData) => { + setIsSubmitting(true) + try { + const submitData = { + ...data, + } + + const res = await createRepo(submitData) + if (res?.code === 200) { + onOpenChange(false) + await getList(true) + } + } finally { + setIsSubmitting(false) + } + } + + return ( + + + + 新建仓库 + + 填写仓库信息以创建新的代码仓库 + + + +
+
+ + +
+ +
+ +