From 82376fea9d28e4e9ffb6b6ac08bd8981924ce6f4 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 3 Aug 2026 20:25:17 +0000 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E7=BC=BA=E5=B0=91=20randomUU?= =?UTF-8?q?ID=20=E7=9A=84=20WebView?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: multica-agent --- src/features/connections/components.tsx | 4 ++-- src/features/connections/model.test.ts | 9 +++++++-- src/features/connections/model.ts | 17 +++++++++++++++-- 3 files changed, 24 insertions(+), 6 deletions(-) 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} />

导入预览