fix: MyProfile key_facts值非字符串时toLowerCase崩溃,加String()保护
This commit is contained in:
@@ -359,7 +359,7 @@ const PROFILE_FACT_KEYS = new Set([
|
||||
|
||||
/** 判断 key 属于画像特征还是个案事实 */
|
||||
function isProfileFact(key: string): boolean {
|
||||
return PROFILE_FACT_KEYS.has(key.toLowerCase())
|
||||
return PROFILE_FACT_KEYS.has(String(key).toLowerCase())
|
||||
}
|
||||
|
||||
|
||||
@@ -396,30 +396,34 @@ const TOPIC_LABELS: Record<string, string> = {
|
||||
|
||||
/** 翻译常问话题 */
|
||||
function translateTopic(topic: string): string {
|
||||
const lower = topic.toLowerCase().trim()
|
||||
return TOPIC_LABELS[lower] || topic
|
||||
const t = String(topic)
|
||||
const lower = t.toLowerCase().trim()
|
||||
return TOPIC_LABELS[lower] || t
|
||||
}
|
||||
|
||||
/** 格式化字段值 */
|
||||
function formatValue(key: string, value: string): string {
|
||||
if (key === 'company_size') return SIZE_LABELS[value] || value
|
||||
if (key === 'risk_tolerance') return RISK_LABELS[value] || value
|
||||
if (key === 'role') return ROLE_LABELS[value] || value
|
||||
if (key === 'decision_style') return DECISION_STYLE_LABELS[value] || value
|
||||
if (key === 'communication_style') return COMMUNICATION_STYLE_LABELS[value] || value
|
||||
if (key === 'industry') return INDUSTRY_LABELS[value] || value
|
||||
return value
|
||||
const v = String(value)
|
||||
if (key === 'company_size') return SIZE_LABELS[v] || v
|
||||
if (key === 'risk_tolerance') return RISK_LABELS[v] || v
|
||||
if (key === 'role') return ROLE_LABELS[v] || v
|
||||
if (key === 'decision_style') return DECISION_STYLE_LABELS[v] || v
|
||||
if (key === 'communication_style') return COMMUNICATION_STYLE_LABELS[v] || v
|
||||
if (key === 'industry') return INDUSTRY_LABELS[v] || v
|
||||
return v
|
||||
}
|
||||
|
||||
/** 翻译 key_facts 的 key */
|
||||
function translateFactKey(key: string): string {
|
||||
return KEY_FACT_LABELS[key.toLowerCase()] || key
|
||||
const k = String(key).toLowerCase()
|
||||
return KEY_FACT_LABELS[k] || String(key)
|
||||
}
|
||||
|
||||
/** 翻译 key_facts 的值 */
|
||||
function translateFactValue(value: string): string {
|
||||
const lower = value.toLowerCase().trim()
|
||||
return KEY_FACT_VALUE_LABELS[lower] || value
|
||||
const v = String(value)
|
||||
const lower = v.toLowerCase().trim()
|
||||
return KEY_FACT_VALUE_LABELS[lower] || v
|
||||
}
|
||||
|
||||
export function MyProfile() {
|
||||
|
||||
Reference in New Issue
Block a user