This commit is contained in:
dengqichen 2025-01-20 16:01:26 +08:00
parent 6a8aa4e55b
commit 0313c02198

View File

@ -379,43 +379,58 @@ const DeploymentConfigModal: React.FC<DeploymentConfigModalProps> = ({open, onCa
</div> </div>
<ScrollArea className="h-[200px] rounded-md border"> <ScrollArea className="h-[200px] rounded-md border">
<div className="space-y-4 p-4"> <div className="space-y-4 p-4">
{fields.map((field, index) => ( {fields.length === 0 ? (
<div key={field.id} className="flex gap-4 items-start"> <div className="h-[160px] flex flex-col items-center justify-center text-center">
<FormField <div className="w-10 h-10 mb-3 text-muted-foreground/60">
control={form.control} <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
name={`envs.${index}.key`} <path d="M20 7h-7M14 17H6M8 7H4M4 17h-2M18 17h4M14 7h8"/>
render={({field}) => ( <path d="M12 20V4"/>
<FormItem className="flex-1"> </svg>
<FormControl> </div>
<Input placeholder="变量名" {...field} /> <div className="text-sm text-muted-foreground/80"></div>
</FormControl> <div className="text-xs text-muted-foreground/60 mt-1">
<FormMessage/> "添加变量"
</FormItem> </div>
)}
/>
<FormField
control={form.control}
name={`envs.${index}.value`}
render={({field}) => (
<FormItem className="flex-1">
<FormControl>
<Input placeholder="变量值" {...field} />
</FormControl>
<FormMessage/>
</FormItem>
)}
/>
<Button
type="button"
variant="ghost"
size="icon"
onClick={() => remove(index)}
className="mt-2"
>
<X className="h-4 w-4"/>
</Button>
</div> </div>
))} ) : (
fields.map((field, index) => (
<div key={field.id} className="flex gap-4 items-start">
<FormField
control={form.control}
name={`envs.${index}.key`}
render={({field}) => (
<FormItem className="flex-1">
<FormControl>
<Input placeholder="变量名" {...field} />
</FormControl>
<FormMessage/>
</FormItem>
)}
/>
<FormField
control={form.control}
name={`envs.${index}.value`}
render={({field}) => (
<FormItem className="flex-1">
<FormControl>
<Input placeholder="变量值" {...field} />
</FormControl>
<FormMessage/>
</FormItem>
)}
/>
<Button
type="button"
variant="ghost"
size="icon"
onClick={() => remove(index)}
className="mt-2"
>
<X className="h-4 w-4"/>
</Button>
</div>
))
)}
</div> </div>
</ScrollArea> </ScrollArea>
</div> </div>