refactor(frontend): fold OutboundFormModal server address/port block into core fields

OutboundFormModal.tsx 1538 -> 1516. Moved the shared connect-target (address/port) block into OutboundCoreProtocolFields at the same render position; dropped the now-unused SERVER_PROTOCOLS import. Snapshots unchanged -> no behavior change. typecheck/lint/build green.
This commit is contained in:
MHSanaei 2026-05-30 17:11:14 +02:00
parent 15ecd0aa78
commit 62870103df
No known key found for this signature in database
GPG key ID: 7E4060F2FBE5AB7A
2 changed files with 23 additions and 24 deletions

View file

@ -53,7 +53,6 @@ import {
MODE_OPTIONS,
NETWORK_OPTIONS,
PROTOCOL_OPTIONS,
SERVER_PROTOCOLS,
UTLS_OPTIONS,
} from './outbound-form-constants';
import {
@ -390,28 +389,6 @@ export default function OutboundFormModal({
<Input placeholder={t('pages.xray.outboundForm.localIpPlaceholder')} />
</Form.Item>
{/* Shared connect target (address + port) for protocols
whose form schema carries them flat at settings root.
Hidden for freedom/blackhole/dns/loopback/wireguard. */}
{SERVER_PROTOCOLS.has(protocol) && (
<>
<Form.Item
label={t('pages.inbounds.address')}
name={['settings', 'address']}
rules={[{ required: true, message: t('pages.xray.outboundForm.addressRequired') }]}
>
<Input />
</Form.Item>
<Form.Item
label={t('pages.inbounds.port')}
name={['settings', 'port']}
rules={[{ required: true, message: t('pages.xray.outboundForm.portRequired') }]}
>
<InputNumber min={1} max={65535} style={{ width: '100%' }} />
</Form.Item>
</>
)}
<OutboundCoreProtocolFields protocol={protocol} />
<OutboundOnlyProtocolFields protocol={protocol} />

View file

@ -10,12 +10,34 @@ import {
import { SSMethodSchema } from '@/schemas/protocols/shared/shadowsocks';
import { antdRule } from '@/utils/zodForm';
import { SECURITY_OPTIONS, SS_METHOD_OPTIONS } from './outbound-form-constants';
import { SECURITY_OPTIONS, SERVER_PROTOCOLS, SS_METHOD_OPTIONS } from './outbound-form-constants';
export function OutboundCoreProtocolFields({ protocol }: { protocol: string }) {
const { t } = useTranslation();
return (
<>
{/* Shared connect target (address + port) for protocols
whose form schema carries them flat at settings root.
Hidden for freedom/blackhole/dns/loopback/wireguard. */}
{SERVER_PROTOCOLS.has(protocol) && (
<>
<Form.Item
label={t('pages.inbounds.address')}
name={['settings', 'address']}
rules={[{ required: true, message: t('pages.xray.outboundForm.addressRequired') }]}
>
<Input />
</Form.Item>
<Form.Item
label={t('pages.inbounds.port')}
name={['settings', 'port']}
rules={[{ required: true, message: t('pages.xray.outboundForm.portRequired') }]}
>
<InputNumber min={1} max={65535} style={{ width: '100%' }} />
</Form.Item>
</>
)}
{(protocol === 'vmess' || protocol === 'vless') && (
<Form.Item
label="ID"