diff --git a/plans/002-ny-import-tunnel-selection-compat.md b/plans/002-ny-import-tunnel-selection-compat.md new file mode 100644 index 0000000..e0efebf --- /dev/null +++ b/plans/002-ny-import-tunnel-selection-compat.md @@ -0,0 +1,7 @@ +- [x] Review current forward import flow and confirm ny import uses tunnel selection +- [x] Define ny compatibility update with tunnel-first behavior and auto port assignment fallback +- [x] Update ny parser to accept alias fields and optional `listen_port` +- [x] Keep import execution bound to selected tunnel and remove entry-selection dependency from ux copy +- [x] Update ny import help text to document optional port auto assignment +- [x] Add parser tests for alias-field compatibility and missing-port auto assignment +- [x] Validate updated import parser tests locally diff --git a/vite-frontend/src/pages/forward.tsx b/vite-frontend/src/pages/forward.tsx index e7d73ae..714369a 100644 --- a/vite-frontend/src/pages/forward.tsx +++ b/vite-frontend/src/pages/forward.tsx @@ -563,11 +563,6 @@ export default function ForwardPage() { const [importData, setImportData] = useState(""); const [importLoading, setImportLoading] = useState(false); const [importFormat, setImportFormat] = useState("flvx"); - const [selectedEntryNode, setSelectedEntryNode] = useState( - null, - ); - const [matchedTunnels, setMatchedTunnels] = useState([]); - const [tunnelSelectModalOpen, setTunnelSelectModalOpen] = useState(false); const [selectedTunnelForImport, setSelectedTunnelForImport] = useState< number | null >(null); @@ -4625,10 +4620,10 @@ export default function ForwardPage() { ) : ( <>

- ny格式:JSON对象,支持多个目标地址(负载均衡) + ny格式:JSON对象,支持多个目标地址(负载均衡),按所选隧道导入

- 格式:{"dest":["地址:端口"],"listen_port":端口,"name":"名称"} + 格式:{"dest":["地址:端口"],"listen_port":端口,"name":"名称"}(listen_port可省略,自动分配端口)

)} @@ -4648,8 +4643,6 @@ export default function ForwardPage() { if (selectedKey) { setImportFormat(selectedKey); setSelectedTunnelForImport(null); - setSelectedEntryNode(null); - setMatchedTunnels([]); setImportData(""); setImportResults([]); } @@ -4663,114 +4656,34 @@ export default function ForwardPage() { - {/* flvx格式:隧道选择 */} - {importFormat === "flvx" && ( - { + const selectedKey = Array.from(keys)[0] as string; - setSelectedTunnelForImport( - selectedKey ? parseInt(selectedKey) : null, - ); - }} - > - {tunnels.map((tunnel) => ( - - {tunnel.name} - - ))} - - )} - - {/* ny格式:入口节点选择 */} - {importFormat === "ny" && ( - - )} - - {/* ny格式:显示匹配的隧道 */} - {importFormat === "ny" && matchedTunnels.length > 0 && ( -
- {matchedTunnels.length === 1 ? ( - - 已匹配隧道:{matchedTunnels[0].name} - - ) : ( - - 找到 {matchedTunnels.length}{" "} - 个匹配隧道,请点击下方按钮选择 - - )} -
- )} - - {/* ny格式:多隧道选择按钮 */} - {importFormat === "ny" && - matchedTunnels.length > 1 && - !selectedTunnelForImport && ( - - )} + {tunnel.name} + + ))} + {/* 输入区域 */}