feat(opencode): add manual provider key input with duplicate check

- Add Provider Key input field for OpenCode providers (between icon and name)
- User must manually enter a unique key instead of auto-generating from name
- Real-time validation: format check and duplicate detection
- Key is immutable after creation (disabled in edit mode)
- Remove slugify auto-generation logic from mutations
- Add beforeNameSlot prop to BasicFormFields for extensibility
- Add i18n translations for zh/en/ja
This commit is contained in:
Jason
2026-01-17 20:28:11 +08:00
parent ad6f5b388b
commit 5bcf5bf382
8 changed files with 142 additions and 27 deletions
@@ -1,5 +1,6 @@
import { useTranslation } from "react-i18next";
import { useState } from "react";
import type { ReactNode } from "react";
import {
FormControl,
FormField,
@@ -24,9 +25,11 @@ import type { ProviderFormData } from "@/lib/schemas/provider";
interface BasicFormFieldsProps {
form: UseFormReturn<ProviderFormData>;
/** Slot to render content between icon and name fields */
beforeNameSlot?: ReactNode;
}
export function BasicFormFields({ form }: BasicFormFieldsProps) {
export function BasicFormFields({ form, beforeNameSlot }: BasicFormFieldsProps) {
const { t } = useTranslation();
const [iconDialogOpen, setIconDialogOpen] = useState(false);
@@ -112,6 +115,9 @@ export function BasicFormFields({ form }: BasicFormFieldsProps) {
</Dialog>
</div>
{/* Slot for additional fields between icon and name */}
{beforeNameSlot}
{/* 基础信息 - 网格布局 */}
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<FormField