diff --git a/src/features/connections/components.tsx b/src/features/connections/components.tsx index 3604c5c..738b348 100644 --- a/src/features/connections/components.tsx +++ b/src/features/connections/components.tsx @@ -1,7 +1,7 @@ import { ChangeEvent, ReactNode, useEffect, useMemo, useState } from "react"; import { Button } from "../../ui"; import { ConnectionAdapter } from "./mockAdapter"; -import { blankConnection, ConnectionConfig, ConnectionRecord, connectionStates, DiagnosticCategory, DiagnosticResult, maskedSecret, parseImportPreview, toSafeExport, validateConnection } from "./model"; +import { blankConnection, ConnectionConfig, ConnectionRecord, connectionStates, createConnectionId, DiagnosticCategory, DiagnosticResult, maskedSecret, parseImportPreview, toSafeExport, validateConnection } from "./model"; const field = (config: ConnectionConfig, onChange: (next: ConnectionConfig) => void) => (key: K, value: ConnectionConfig[K]) => onChange({ ...config, [key]: value }); @@ -103,7 +103,7 @@ export function ConnectionCenter({ adapter, developmentMode = false }: { adapter const importPreview = () => { try { setEditing(parseImportPreview(importText)); setNotice("导入预览已加载;秘密字段已清空,保存前请确认。"); } catch (error) { setNotice(error instanceof Error ? error.message : "导入失败"); } }; const exportRecord = (record: ConnectionRecord) => { const safe = JSON.stringify(toSafeExport(record.config), null, 2); setNotice(`安全导出预览(不含 Token、密码和客户端私钥):\n${safe}`); }; if (editing) return setEditing(undefined)} onSave={async (config) => { await adapter.save(config); await refresh(); setSelected(config.id); setEditing(undefined); setNotice("配置已保存到内存 mock adapter;尚未建立网络连接。"); }} />; - return
setEditing(blankConnection())} onCopy={(record) => setEditing({ ...structuredClone(record.config), id: crypto.randomUUID(), name: `${record.config.name} 副本`, auth: { ...record.config.auth, secret: "" }, proxy: { ...record.config.proxy, password: "" }, tls: { ...record.config.tls, clientKey: "" } })} onExport={exportRecord} onDelete={setDeleting} /> + return
setEditing(blankConnection())} onCopy={(record) => setEditing({ ...structuredClone(record.config), id: createConnectionId(), name: `${record.config.name} 副本`, auth: { ...record.config.auth, secret: "" }, proxy: { ...record.config.proxy, password: "" }, tls: { ...record.config.tls, clientKey: "" } })} onExport={exportRecord} onDelete={setDeleting} />

导入预览