From 02ecc231e7229afd1081edd4a7295307bf6fa985 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A2=A8=E9=9B=AA?= Date: Sat, 29 Aug 2026 10:54:03 +0800 Subject: [PATCH] feat: remove quick-setup; autofill secrets on create + generate helper --- .../src/components/ListenerConfigFields.tsx | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/frontend/src/components/ListenerConfigFields.tsx b/frontend/src/components/ListenerConfigFields.tsx index cc6e42a..1306fb7 100644 --- a/frontend/src/components/ListenerConfigFields.tsx +++ b/frontend/src/components/ListenerConfigFields.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { Form, Input, InputNumber, Select, Switch, Divider, Alert, Space, Typography, Button, Card, Radio, } from 'antd'; +import { generateMaterial } from '../api/listeners'; import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons'; import { useI18n } from '../i18n'; @@ -694,6 +695,27 @@ type Props = { protocol?: string }; const ListenerConfigFields: React.FC = ({ protocol }) => { const { t } = useI18n(); + const form = Form.useFormInstance(); + const gen = async (kind: string, cipher?: string) => { + try { + const data = await generateMaterial({ kind, cipher }); + if (kind === 'reality') { + form.setFieldsValue({ + reality_private_key: data.private_key, + reality_short_id: data.short_id ? [data.short_id] : undefined, + }); + } else if (kind === 'uuid' && data.uuid) { + form.setFieldsValue({ uuid: data.uuid }); + } else if ((kind === 'password' || kind === 'ss-password') && data.password) { + form.setFieldsValue({ password: data.password }); + } else if (kind === 'short-id' && data.short_id) { + form.setFieldsValue({ reality_short_id: [data.short_id] }); + } + } catch (e: any) { + // keep silent-ish; antd message may not be imported + console.error(e); + } + }; if (!protocol) { return ( @@ -737,8 +759,8 @@ const ListenerConfigFields: React.FC = ({ protocol }) => { + + - + gen('reality')}>{t('common.generate') || 'Generate'}} /> -