From c522681c4cc3997e018128fec2cf779d1a27028e Mon Sep 17 00:00:00 2001 From: catlog22 Date: Mon, 2 Feb 2026 10:46:36 +0800 Subject: [PATCH] fix(frontend): fix i18n and runtime error in EndpointList Fix hardcoded English labels in cache strategy display and prevent runtime error when filePatterns is undefined. Changes: - Replace hardcoded "TTL:", "Max:", "Patterns:" with formatMessage calls - Add optional chaining for filePatterns.length to prevent undefined error - Add "filePatterns" i18n key to en/zh api-settings.json --- ccw/frontend/src/components/api-settings/EndpointList.tsx | 8 ++++---- ccw/frontend/src/locales/en/api-settings.json | 1 + ccw/frontend/src/locales/zh/api-settings.json | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ccw/frontend/src/components/api-settings/EndpointList.tsx b/ccw/frontend/src/components/api-settings/EndpointList.tsx index 67252174..6053e5e4 100644 --- a/ccw/frontend/src/components/api-settings/EndpointList.tsx +++ b/ccw/frontend/src/components/api-settings/EndpointList.tsx @@ -92,10 +92,10 @@ function EndpointCard({ )} {endpoint.cacheStrategy.enabled && (
- TTL: {endpoint.cacheStrategy.ttlMinutes}m - Max: {endpoint.cacheStrategy.maxSizeKB}KB - {endpoint.cacheStrategy.filePatterns.length > 0 && ( - Patterns: {endpoint.cacheStrategy.filePatterns.length} + {formatMessage({ id: 'apiSettings.endpoints.cacheTTL' })}: {endpoint.cacheStrategy.ttlMinutes}m + {formatMessage({ id: 'apiSettings.endpoints.cacheMaxSize' })}: {endpoint.cacheStrategy.maxSizeKB}KB + {(endpoint.cacheStrategy.filePatterns?.length || 0) > 0 && ( + {formatMessage({ id: 'apiSettings.endpoints.filePatterns' })}: {endpoint.cacheStrategy.filePatterns?.length || 0} )}
)} diff --git a/ccw/frontend/src/locales/en/api-settings.json b/ccw/frontend/src/locales/en/api-settings.json index 8a3017f1..2f8474c6 100644 --- a/ccw/frontend/src/locales/en/api-settings.json +++ b/ccw/frontend/src/locales/en/api-settings.json @@ -167,6 +167,7 @@ "enableContextCaching": "Enable context caching", "cacheTTL": "Cache TTL (minutes)", "cacheMaxSize": "Max Size (KB)", + "filePatterns": "Patterns", "autoCachePatterns": "Auto-cache patterns", "filePatternsHint": "Comma-separated glob patterns (e.g., *.md,*.ts)", "enabled": "Enabled", diff --git a/ccw/frontend/src/locales/zh/api-settings.json b/ccw/frontend/src/locales/zh/api-settings.json index 1ffa0792..60cfacb4 100644 --- a/ccw/frontend/src/locales/zh/api-settings.json +++ b/ccw/frontend/src/locales/zh/api-settings.json @@ -164,6 +164,7 @@ "enableContextCaching": "启用上下文缓存", "cacheTTL": "缓存 TTL(分钟)", "cacheMaxSize": "最大大小(KB)", + "filePatterns": "模式数", "autoCachePatterns": "自动缓存模式", "filePatternsHint": "逗号分隔的 glob 模式(例如:*.md,*.ts)", "enabled": "已启用",