fix: 修复微信配置编辑不传递脱敏
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 3m57s

This commit is contained in:
sexygoat
2026-04-13 14:35:19 +08:00
parent 1acb9db38e
commit b5eb4fdbce
2 changed files with 35 additions and 31 deletions

View File

@@ -7,9 +7,9 @@
"apiKey": "sk-ZBGcMXCdwtSK7G35s" "apiKey": "sk-ZBGcMXCdwtSK7G35s"
} }
}, },
"minimax": { "google": {
"options": { "options": {
"baseURL": "http://45.155.220.179:8317/v1", "baseURL": "http://45.155.220.179:8317/v1beta",
"apiKey": "sk-ZBGcMXCdwtSK7G35s" "apiKey": "sk-ZBGcMXCdwtSK7G35s"
} }
} }

View File

@@ -788,12 +788,11 @@
}) })
} }
// 处理敏感字段值 - 如果是***或[已配置]等特殊值,转换为空字符串 // 检查是否是脱敏数据
const processSensitiveField = (value: string | undefined | null): string => { const isMaskedData = (value: string | undefined | null): boolean => {
if (!value || value === '***' || value.includes('[已配置]') || value.includes('[未配置]')) { if (!value) return false
return '' // 检查是否包含脱敏标记:纯星号、已配置标记、或包含连续星号(脱敏数据如Wuha***1218)
} return value === '***' || value.includes('[已配置]') || value.includes('[未配置]') || /\*{2,}/.test(value)
return value
} }
// 显示编辑对话框 // 显示编辑对话框
@@ -803,33 +802,33 @@
const res = await WechatConfigService.getWechatConfigById(row.id) const res = await WechatConfigService.getWechatConfigById(row.id)
if (res.code === 0 && res.data) { if (res.code === 0 && res.data) {
const detail = res.data const detail = res.data
// 赋值表单数据 // 赋值表单数据(保持脱敏数据原样显示)
Object.assign(form, { Object.assign(form, {
id: detail.id, id: detail.id,
name: detail.name, name: detail.name,
provider_type: detail.provider_type, provider_type: detail.provider_type,
description: detail.description || '', description: detail.description || '',
miniapp_app_id: detail.miniapp_app_id || '', miniapp_app_id: detail.miniapp_app_id || '',
miniapp_app_secret: processSensitiveField(detail.miniapp_app_secret), miniapp_app_secret: detail.miniapp_app_secret || '',
oa_app_id: detail.oa_app_id || '', oa_app_id: detail.oa_app_id || '',
oa_app_secret: processSensitiveField(detail.oa_app_secret), oa_app_secret: detail.oa_app_secret || '',
oa_token: processSensitiveField(detail.oa_token), oa_token: detail.oa_token || '',
oa_aes_key: processSensitiveField(detail.oa_aes_key), oa_aes_key: detail.oa_aes_key || '',
oa_oauth_redirect_url: detail.oa_oauth_redirect_url || '', oa_oauth_redirect_url: detail.oa_oauth_redirect_url || '',
wx_mch_id: detail.wx_mch_id || '', wx_mch_id: detail.wx_mch_id || '',
wx_api_v2_key: processSensitiveField(detail.wx_api_v2_key), wx_api_v2_key: detail.wx_api_v2_key || '',
wx_api_v3_key: processSensitiveField(detail.wx_api_v3_key), wx_api_v3_key: detail.wx_api_v3_key || '',
wx_notify_url: detail.wx_notify_url || '', wx_notify_url: detail.wx_notify_url || '',
wx_serial_no: detail.wx_serial_no || '', wx_serial_no: detail.wx_serial_no || '',
wx_cert_content: processSensitiveField(detail.wx_cert_content), wx_cert_content: detail.wx_cert_content || '',
wx_key_content: processSensitiveField(detail.wx_key_content), wx_key_content: detail.wx_key_content || '',
fy_api_url: detail.fy_api_url || '', fy_api_url: detail.fy_api_url || '',
fy_ins_cd: detail.fy_ins_cd || '', fy_ins_cd: detail.fy_ins_cd || '',
fy_mchnt_cd: detail.fy_mchnt_cd || '', fy_mchnt_cd: detail.fy_mchnt_cd || '',
fy_term_id: detail.fy_term_id || '', fy_term_id: detail.fy_term_id || '',
fy_notify_url: detail.fy_notify_url || '', fy_notify_url: detail.fy_notify_url || '',
fy_private_key: processSensitiveField(detail.fy_private_key), fy_private_key: detail.fy_private_key || '',
fy_public_key: processSensitiveField(detail.fy_public_key) fy_public_key: detail.fy_public_key || ''
}) })
dialogType.value = 'edit' dialogType.value = 'edit'
dialogVisible.value = true dialogVisible.value = true
@@ -856,6 +855,11 @@
// 只需要什么都不做,下次打开时会重新赋值 // 只需要什么都不做,下次打开时会重新赋值
} }
// 判断字段值是否有效(不是空且不是脱敏数据)
const isValidFieldValue = (value: string | undefined): boolean => {
return !!value && !isMaskedData(value)
}
// 提交表单 // 提交表单
const handleSubmit = async () => { const handleSubmit = async () => {
if (!formRef.value) return if (!formRef.value) return
@@ -898,19 +902,19 @@
name: form.name, name: form.name,
description: form.description || undefined description: form.description || undefined
} }
// 只有填写了新值才更新敏感字段 // 只有填写了有效的新值才更新敏感字段(不是空值且不是脱敏数据)
if (form.miniapp_app_secret) data.miniapp_app_secret = form.miniapp_app_secret if (isValidFieldValue(form.miniapp_app_secret)) data.miniapp_app_secret = form.miniapp_app_secret
if (form.oa_app_secret) data.oa_app_secret = form.oa_app_secret if (isValidFieldValue(form.oa_app_secret)) data.oa_app_secret = form.oa_app_secret
if (form.oa_token) data.oa_token = form.oa_token if (isValidFieldValue(form.oa_token)) data.oa_token = form.oa_token
if (form.oa_aes_key) data.oa_aes_key = form.oa_aes_key if (isValidFieldValue(form.oa_aes_key)) data.oa_aes_key = form.oa_aes_key
if (form.wx_api_v2_key) data.wx_api_v2_key = form.wx_api_v2_key if (isValidFieldValue(form.wx_api_v2_key)) data.wx_api_v2_key = form.wx_api_v2_key
if (form.wx_api_v3_key) data.wx_api_v3_key = form.wx_api_v3_key if (isValidFieldValue(form.wx_api_v3_key)) data.wx_api_v3_key = form.wx_api_v3_key
if (form.wx_cert_content) data.wx_cert_content = form.wx_cert_content if (isValidFieldValue(form.wx_cert_content)) data.wx_cert_content = form.wx_cert_content
if (form.wx_key_content) data.wx_key_content = form.wx_key_content if (isValidFieldValue(form.wx_key_content)) data.wx_key_content = form.wx_key_content
if (form.fy_private_key) data.fy_private_key = form.fy_private_key if (isValidFieldValue(form.fy_private_key)) data.fy_private_key = form.fy_private_key
if (form.fy_public_key) data.fy_public_key = form.fy_public_key if (isValidFieldValue(form.fy_public_key)) data.fy_public_key = form.fy_public_key
// 非敏感字段总是更新 // 非敏感字段:如果有值就更新
if (form.miniapp_app_id) data.miniapp_app_id = form.miniapp_app_id if (form.miniapp_app_id) data.miniapp_app_id = form.miniapp_app_id
if (form.oa_app_id) data.oa_app_id = form.oa_app_id if (form.oa_app_id) data.oa_app_id = form.oa_app_id
if (form.oa_oauth_redirect_url) data.oa_oauth_redirect_url = form.oa_oauth_redirect_url if (form.oa_oauth_redirect_url) data.oa_oauth_redirect_url = form.oa_oauth_redirect_url