From 8b1cf2e6fe771ba991cdeb6e9cc048dd57a3a21c Mon Sep 17 00:00:00 2001 From: tinkle-community Date: Tue, 9 Dec 2025 19:08:04 +0800 Subject: [PATCH] fix: respect transport_encryption setting in API config functions When TRANSPORT_ENCRYPTION=false, updateModelConfigs and updateExchangeConfigsEncrypted now send plain JSON instead of attempting encryption which would fail with an empty public key. --- web/src/lib/api.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/web/src/lib/api.ts b/web/src/lib/api.ts index c5db616a..e96bc468 100644 --- a/web/src/lib/api.ts +++ b/web/src/lib/api.ts @@ -169,6 +169,16 @@ export const api = { }, async updateModelConfigs(request: UpdateModelConfigRequest): Promise { + // 检查是否启用了传输加密 + const config = await CryptoService.fetchCryptoConfig() + + if (!config.transport_encryption) { + // 传输加密禁用时,直接发送明文 + const result = await httpClient.put(`${API_BASE}/models`, request) + if (!result.success) throw new Error('更新模型配置失败') + return + } + // 获取RSA公钥 const publicKey = await CryptoService.fetchPublicKey() @@ -214,10 +224,20 @@ export const api = { if (!result.success) throw new Error('更新交易所配置失败') }, - // 使用加密传输更新交易所配置 + // 使用加密传输更新交易所配置(自动检测是否启用加密) async updateExchangeConfigsEncrypted( request: UpdateExchangeConfigRequest ): Promise { + // 检查是否启用了传输加密 + const config = await CryptoService.fetchCryptoConfig() + + if (!config.transport_encryption) { + // 传输加密禁用时,直接发送明文 + const result = await httpClient.put(`${API_BASE}/exchanges`, request) + if (!result.success) throw new Error('更新交易所配置失败') + return + } + // 获取RSA公钥 const publicKey = await CryptoService.fetchPublicKey()