From 2be473aea36b55fd058d121b795d58b7e7aa49ca Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Sat, 30 May 2026 17:29:56 +0200 Subject: [PATCH] refactor(frontend): split outbound-only protocol forms into per-protocol files Replace the grouped outbound-only-fields.tsx + outbound-freedom-fields.tsx with one file per protocol under outbounds/protocols/: freedom.tsx, blackhole.tsx, dns.tsx, loopback.tsx (+ barrel). Matches the prompt's 1-file-per-protocol structure. Outbound snapshots unchanged -> no behavior change. typecheck/lint/build green. --- .../xray/outbounds/OutboundFormModal.tsx | 9 +- .../xray/outbounds/outbound-only-fields.tsx | 92 ------------------- .../xray/outbounds/protocols/blackhole.tsx | 17 ++++ .../pages/xray/outbounds/protocols/dns.tsx | 70 ++++++++++++++ .../freedom.tsx} | 2 +- .../pages/xray/outbounds/protocols/index.ts | 4 + .../xray/outbounds/protocols/loopback.tsx | 11 +++ 7 files changed, 108 insertions(+), 97 deletions(-) delete mode 100644 frontend/src/pages/xray/outbounds/outbound-only-fields.tsx create mode 100644 frontend/src/pages/xray/outbounds/protocols/blackhole.tsx create mode 100644 frontend/src/pages/xray/outbounds/protocols/dns.tsx rename frontend/src/pages/xray/outbounds/{outbound-freedom-fields.tsx => protocols/freedom.tsx} (99%) create mode 100644 frontend/src/pages/xray/outbounds/protocols/index.ts create mode 100644 frontend/src/pages/xray/outbounds/protocols/loopback.tsx diff --git a/frontend/src/pages/xray/outbounds/OutboundFormModal.tsx b/frontend/src/pages/xray/outbounds/OutboundFormModal.tsx index af65ede0..6435ea48 100644 --- a/frontend/src/pages/xray/outbounds/OutboundFormModal.tsx +++ b/frontend/src/pages/xray/outbounds/OutboundFormModal.tsx @@ -62,9 +62,8 @@ import { newStreamSlice, } from './outbound-form-helpers'; import { OutboundCoreProtocolFields } from './outbound-core-fields'; -import { OutboundOnlyProtocolFields } from './outbound-only-fields'; -import { FreedomOutboundFields } from './outbound-freedom-fields'; import { WireguardOutboundFields } from './outbound-wireguard-fields'; +import { BlackholeFields, DnsFields, FreedomFields, LoopbackFields } from './protocols'; import './OutboundFormModal.css'; // Pattern A rewrite of OutboundFormModal. Built as a sibling `.new.tsx` @@ -391,9 +390,11 @@ export default function OutboundFormModal({ - + {protocol === 'loopback' && } + {protocol === 'blackhole' && } + {protocol === 'dns' && } - {protocol === 'freedom' && } + {protocol === 'freedom' && } {protocol === 'vless' && ( diff --git a/frontend/src/pages/xray/outbounds/outbound-only-fields.tsx b/frontend/src/pages/xray/outbounds/outbound-only-fields.tsx deleted file mode 100644 index e491a796..00000000 --- a/frontend/src/pages/xray/outbounds/outbound-only-fields.tsx +++ /dev/null @@ -1,92 +0,0 @@ -import { useTranslation } from 'react-i18next'; -import { Button, Form, Input, InputNumber, Select } from 'antd'; -import { DeleteOutlined, PlusOutlined } from '@ant-design/icons'; - -import { DNSRuleActions } from '@/schemas/primitives'; - -export function OutboundOnlyProtocolFields({ protocol }: { protocol: string }) { - const { t } = useTranslation(); - return ( - <> - {protocol === 'loopback' && ( - - - - )} - - {protocol === 'blackhole' && ( - - - - - - - - - - - - - - {(fields, { add, remove }) => ( - <> - -