diff --git a/src/actions/gateway.ts b/src/actions/gateway.ts index 25f3d0e..ed0f0aa 100644 --- a/src/actions/gateway.ts +++ b/src/actions/gateway.ts @@ -14,7 +14,8 @@ export async function createGateway(data: { host?: string type: number status: number - secret: string + secret?: string + port?: number }) { return callByUser("/api/admin/proxy/create", data) } diff --git a/src/app/(root)/gateway/create.tsx b/src/app/(root)/gateway/create.tsx index db51c9d..8c83702 100644 --- a/src/app/(root)/gateway/create.tsx +++ b/src/app/(root)/gateway/create.tsx @@ -48,7 +48,8 @@ const schema = z.object({ .or(z.literal("")), type: z.string().optional(), status: z.string().optional(), - secret: z.string().min(1, "请填写密钥"), + secret: z.string().optional(), + proxy_port: z.string().optional(), }) export default function CreatePage(props: { onSuccess?: () => void }) { @@ -63,6 +64,7 @@ export default function CreatePage(props: { onSuccess?: () => void }) { type: "1", status: "0", secret: "", + proxy_port: "", }, }) @@ -75,7 +77,8 @@ export default function CreatePage(props: { onSuccess?: () => void }) { host: data?.host.trim(), type: data.type ? Number(data.type) : 0, status: data.status ? Number(data.status) : 0, - secret: data.secret.trim(), + secret: data.secret?.trim() ?? "", + port: Number(data.proxy_port?.trim()) ?? "", } const res = await createGateway(payload) @@ -110,6 +113,7 @@ export default function CreatePage(props: { onSuccess?: () => void }) { const typeOptions = [ { value: "1", label: "自有" }, { value: "2", label: "白银" }, + { value: "3", label: "GOST" }, ] return ( @@ -186,6 +190,24 @@ export default function CreatePage(props: { onSuccess?: () => void }) { )} /> + ( + + 端口: + + {fieldState.invalid && fieldState.error && ( + + )} + + )} + /> (row.original.type === 1 ? "自有" : "白银"), + cell: ({ row }) => { + const typeMap: Record = { + 1: "自有", + 2: "白银", + 3: "GOST", + } + return typeMap[row.original.type] ?? "" + }, }, { header: "状态",