From 2d74dbe7adf651ca6cb66928fa1b08ea25f6f327 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Tue, 26 May 2026 01:11:51 +0200 Subject: [PATCH] refactor(frontend): lift outbound option dictionaries to schemas/primitives MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds schemas/primitives/options.ts with UTLS_FINGERPRINT, ALPN_OPTION, SNIFFING_OPTION, USERS_SECURITY, MODE_OPTION (all identical between models/inbound.ts and models/outbound.ts) plus the outbound-only WireguardDomainStrategy, Address_Port_Strategy, and DNSRuleActions. OutboundFormModal now pulls 9 consts from primitives. Only `Outbound` (the class) and `SSMethods` (whose inbound/outbound versions diverge by 2 legacy aliases — keep the picker open for the Pattern A rewrite) still come from @/models/outbound. Drops three stale `as string[]` casts on what are now readonly tuples. --- frontend/src/pages/xray/OutboundFormModal.tsx | 13 ++-- frontend/src/schemas/primitives/index.ts | 1 + frontend/src/schemas/primitives/options.ts | 62 +++++++++++++++++++ 3 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 frontend/src/schemas/primitives/options.ts diff --git a/frontend/src/pages/xray/OutboundFormModal.tsx b/frontend/src/pages/xray/OutboundFormModal.tsx index 4d628b57..0e4ea70d 100644 --- a/frontend/src/pages/xray/OutboundFormModal.tsx +++ b/frontend/src/pages/xray/OutboundFormModal.tsx @@ -18,10 +18,9 @@ import { SyncOutlined, PlusOutlined, MinusOutlined, DeleteOutlined } from '@ant- import { Wireguard } from '@/utils'; import InputAddon from '@/components/InputAddon'; +import { Outbound, SSMethods } from '@/models/outbound'; import { - Outbound, - Protocols, - SSMethods, + OutboundProtocols as Protocols, TLS_FLOW_CONTROL, UTLS_FINGERPRINT, ALPN_OPTION, @@ -32,7 +31,7 @@ import { Address_Port_Strategy, MODE_OPTION, DNSRuleActions, -} from '@/models/outbound'; +} from '@/schemas/primitives'; import FinalMaskForm from '@/components/FinalMaskForm'; import JsonEditor from '@/components/JsonEditor'; import { OutboundTagSchema } from '@/schemas/xray'; @@ -494,7 +493,7 @@ function FreedomFields({ ob, refresh }: FieldProps) { { rule.action = v; refresh(); }} - options={(DNSRuleActions as string[]).map((a) => ({ value: a, label: a }))} + options={DNSRuleActions.map((a) => ({ value: a, label: a }))} /> @@ -775,7 +774,7 @@ function WireguardFields({ ob, refresh, regenerate, t }: TFieldProps & { regener