From 1330aea3320273ffb7d4803b673548e8a6114a60 Mon Sep 17 00:00:00 2001 From: zhx Date: Thu, 21 May 2026 15:32:11 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=98=E9=92=A5=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/games/api.ts | 3 ++- src/features/games/games.module.css | 6 ++++++ src/features/games/hooks/useGamesPage.js | 6 +++--- src/features/games/pages/GameListPage.jsx | 8 +++++--- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/features/games/api.ts b/src/features/games/api.ts index 562b3ab..af090bd 100644 --- a/src/features/games/api.ts +++ b/src/features/games/api.ts @@ -10,7 +10,7 @@ export interface GamePlatformDto { apiBaseUrl: string; // 服务端按 adapterType 选择厂商协议:demo/yomi_v4/leadercc_v1。 adapterType: string; - // callbackSecret 只用于提交更新;列表返回不会携带明文。 + // callbackSecret 由后台列表返回,用于配置页直接核对和轮换厂商 key。 callbackSecret?: string; callbackSecretSet: boolean; callbackIpWhitelist: string[]; @@ -130,6 +130,7 @@ function normalizePlatform(platform: Partial): GamePlatformDto status: stringValue(platform.status || "active"), apiBaseUrl: stringValue(platform.apiBaseUrl), adapterType: stringValue(platform.adapterType || "demo"), + callbackSecret: stringValue(platform.callbackSecret), callbackSecretSet: Boolean(platform.callbackSecretSet), callbackIpWhitelist: Array.isArray(platform.callbackIpWhitelist) ? platform.callbackIpWhitelist.map(String).filter(Boolean) diff --git a/src/features/games/games.module.css b/src/features/games/games.module.css index 5ba53cb..113c24c 100644 --- a/src/features/games/games.module.css +++ b/src/features/games/games.module.css @@ -44,6 +44,12 @@ color: var(--text-secondary); } +.secretMeta { + font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; + overflow-wrap: anywhere; + white-space: normal; +} + .switchOnlyField { display: inline-flex; min-height: 56px; diff --git a/src/features/games/hooks/useGamesPage.js b/src/features/games/hooks/useGamesPage.js index 6d3880d..e50edb6 100644 --- a/src/features/games/hooks/useGamesPage.js +++ b/src/features/games/hooks/useGamesPage.js @@ -33,7 +33,7 @@ const defaultPlatformForm = { apiBaseUrl: "", // 默认 demo 兼容本地调试;真实厂商在后台切到 yomi_v4/leadercc_v1。 adapterType: "demo", - // 密钥只写不读,打开编辑弹窗时始终为空,避免明文停留在浏览器状态里。 + // 后台现在会回显厂商 key,编辑弹窗直接显示当前值;提交空值仍代表“不覆盖旧值”。 callbackSecret: "", callbackSecretSet: false, callbackIpWhitelistText: "", @@ -281,8 +281,8 @@ function platformToForm(platform) { status: platform.status || "active", apiBaseUrl: platform.apiBaseUrl || "", adapterType: platform.adapterType || "demo", - // 后端不会返回 callbackSecret 明文;这里保留空字符串代表“不更新密钥”。 - callbackSecret: "", + // 使用后端返回的当前密钥,方便运营直接核对;用户清空提交时后端会保留旧值。 + callbackSecret: platform.callbackSecret || "", callbackSecretSet: Boolean(platform.callbackSecretSet), callbackIpWhitelistText: (platform.callbackIpWhitelist || []).join("\n"), adapterConfigJson: platform.adapterConfigJson || "{}", diff --git a/src/features/games/pages/GameListPage.jsx b/src/features/games/pages/GameListPage.jsx index b9a5cd8..7cf2988 100644 --- a/src/features/games/pages/GameListPage.jsx +++ b/src/features/games/pages/GameListPage.jsx @@ -448,10 +448,9 @@ function PlatformFormDialog({ form, loading, mode, open, page, onClose, onSubmit onChange={(event) => page.setPlatformForm({ ...form, apiBaseUrl: event.target.value })} /> ) : null} - {/* 密钥不回显;编辑平台时留空表示沿用旧密钥,输入新值才覆盖。 */} + {/* 后台直接回显当前厂商 key;清空保存时后端保持旧密钥,输入新值才轮换。 */} page.setPlatformForm({ ...form, callbackSecret: event.target.value })} /> @@ -505,6 +504,9 @@ function PlatformManageDialog({ open, page, onClose }) { {platform.platformCode} / {platform.adapterType || "demo"} {platform.apiBaseUrl ? {platform.apiBaseUrl} : null} + + 密钥:{platform.callbackSecret || "未配置"} +