秘钥显示

This commit is contained in:
zhx 2026-05-21 15:32:11 +08:00
parent 5821154fb1
commit 1330aea332
4 changed files with 16 additions and 7 deletions

View File

@ -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>): 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)

View File

@ -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;

View File

@ -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 || "{}",

View File

@ -448,10 +448,9 @@ function PlatformFormDialog({ form, loading, mode, open, page, onClose, onSubmit
onChange={(event) => page.setPlatformForm({ ...form, apiBaseUrl: event.target.value })}
/>
) : null}
{/* 密钥不回显;编辑平台时留空表示沿用旧密钥,输入新值才覆盖。 */}
{/* 后台直接回显当前厂商 key清空保存时后端保持旧密钥输入新值才轮换。 */}
<TextField
label={form.callbackSecretSet ? "回调密钥(已配置)" : "回调密钥"}
type="password"
label="回调密钥"
value={form.callbackSecret}
onChange={(event) => page.setPlatformForm({ ...form, callbackSecret: event.target.value })}
/>
@ -505,6 +504,9 @@ function PlatformManageDialog({ open, page, onClose }) {
{platform.platformCode} / {platform.adapterType || "demo"}
</span>
{platform.apiBaseUrl ? <span className={styles.meta}>{platform.apiBaseUrl}</span> : null}
<span className={`${styles.meta} ${styles.secretMeta}`}>
密钥{platform.callbackSecret || "未配置"}
</span>
</div>
<div className={styles.platformActions}>
<span className={styles.meta}>