From 45ed2ed72ab9eafaa85dbf6527c4db6090693f4c Mon Sep 17 00:00:00 2001 From: sophie <16087569+sophie_liang@user.noreply.gitee.com> Date: Thu, 9 Apr 2026 13:41:22 +0800 Subject: [PATCH] fix: fix serveral bugs of frontend --- frontend/src/i18n.ts | 41 ++++++++++++++++++-- frontend/src/views/AdminView.vue | 57 ++++++++++++++++++++++------ frontend/src/views/ProfileView.vue | 4 +- frontend/src/views/WorkspaceView.vue | 21 +++++++--- 4 files changed, 102 insertions(+), 21 deletions(-) diff --git a/frontend/src/i18n.ts b/frontend/src/i18n.ts index 919f6fc4..81f8cc79 100644 --- a/frontend/src/i18n.ts +++ b/frontend/src/i18n.ts @@ -1,4 +1,4 @@ - + import { createI18n } from 'vue-i18n'; const messages = { @@ -34,8 +34,8 @@ const messages = { forgotPasswordDesc: 'Enter your email to reset your password', findPassword: 'Find Password', announcements: 'Announcements', - passwordResetEmailSent: 'If the account exists, a reset link has been sent to your email.', - passwordResetRequestFailed: 'Failed to request password reset', + passwordResetEmailSent: '如果账号存在,重置链接已发送到您的邮箱。', + passwordResetRequestFailed: '请求密码重置失败', wecomLogin: 'Login with WeCom', wecomConnecting: 'Connecting to WeCom...', wecomStartFailed: 'Failed to start WeCom login', @@ -514,6 +514,7 @@ const messages = { employee_id: 'Employee ID', role: 'Role', status: 'Status', + is_active: 'Is Active', language: 'Language', default_agent_id: 'Default Agent ID', default_agent: 'Default Agent', @@ -528,10 +529,13 @@ const messages = { agent_id: 'Agent ID', agent_name: 'Agent Name', conversation_id: 'Conversation ID', + attribution_parts: 'Attribution Parts', session_id: 'Session ID', message_id: 'Message ID', question: 'Question', + query: 'Query', answer: 'Answer', + retriever_resources: 'Retriever Resources', response: 'Response', content: 'Content', description: 'Description', @@ -542,10 +546,12 @@ const messages = { comment: 'Comment', model: 'Model', tokens: 'Tokens', + tokens_used: 'Tokens Used', tokens_prompt: 'Prompt Tokens', tokens_completion: 'Completion Tokens', total_tokens: 'Total Tokens', latency_ms: 'Latency (ms)', + latency: 'Latency', cost: 'Cost', ip: 'IP', user_agent: 'User Agent', @@ -698,8 +704,17 @@ const messages = { rememberMe: '30天内免登录', forgotPasswordDesc: '输入您的邮箱以重置密码', findPassword: '找回密码', + announcements: '公告', + passwordResetEmailSent: '如果账号存在,重置链接已发送到您的邮箱。', + passwordResetRequestFailed: '请求密码重置失败', wecomLogin: '企业微信登录', - wecomConnecting: '正在连接企业微信...' + wecomConnecting: '正在连接企业微信...', + wecomStartFailed: '启动企业微信登录失败', + wecomInvalidState: '企业微信登录状态无效', + wecomStateExpired: '企业微信登录会话已过期,请重试。', + wecomBindRequired: '当前企业微信账号未绑定本地用户,请联系管理员。', + wecomAccountDisabled: '账号已禁用,请联系管理员。', + wecomLoginFailed: '企业微信登录失败' }, landing: { hero: { @@ -1167,6 +1182,7 @@ const messages = { employee_id: '工号', role: '角色', status: '状态', + is_active: '是否启用', language: '语言', default_agent_id: '默认应用 ID', default_agent: '默认应用', @@ -1181,10 +1197,13 @@ const messages = { agent_id: '应用 ID', agent_name: '应用名称', conversation_id: '会话 ID', + attribution_parts: '归因片段', session_id: '会话 ID', message_id: '消息 ID', question: '问题', + query: '提问', answer: '回答', + retriever_resources: '检索资源', response: '回复', content: '内容', description: '描述', @@ -1195,10 +1214,12 @@ const messages = { comment: '评论', model: '模型', tokens: 'Token 数', + tokens_used: '已用 Token', tokens_prompt: '提示词 Token', tokens_completion: '补全 Token', total_tokens: '总 Token', latency_ms: '延迟(毫秒)', + latency: '延迟', cost: '费用', ip: 'IP', user_agent: '用户代理', @@ -1802,6 +1823,7 @@ const messages = { employee_id: '工號', role: '角色', status: '狀態', + is_active: '是否啟用', language: '語言', default_agent_id: '默認應用 ID', default_agent: '默認應用', @@ -1816,10 +1838,13 @@ const messages = { agent_id: '應用 ID', agent_name: '應用名稱', conversation_id: '會話 ID', + attribution_parts: '歸因片段', session_id: '會話 ID', message_id: '消息 ID', question: '問題', + query: '提問', answer: '回答', + retriever_resources: '檢索資源', response: '回覆', content: '內容', description: '描述', @@ -1830,10 +1855,12 @@ const messages = { comment: '評論', model: '模型', tokens: 'Token 數', + tokens_used: '已用 Token', tokens_prompt: '提示詞 Token', tokens_completion: '補全 Token', total_tokens: '總 Token', latency_ms: '延遲(毫秒)', + latency: '延遲', cost: '費用', ip: 'IP', user_agent: '用戶代理', @@ -2437,6 +2464,7 @@ const messages = { employee_id: 'รหัสพนักงาน', role: 'บทบาท', status: 'สถานะ', + is_active: 'เปิดใช้งาน', language: 'ภาษา', default_agent_id: 'รหัสตัวแทนเริ่มต้น', default_agent: 'ตัวแทนเริ่มต้น', @@ -2451,10 +2479,13 @@ const messages = { agent_id: 'รหัสตัวแทน', agent_name: 'ชื่อตัวแทน', conversation_id: 'รหัสบทสนทนา', + attribution_parts: 'ส่วนที่อ้างอิง', session_id: 'รหัสเซสชัน', message_id: 'รหัสข้อความ', question: 'คำถาม', + query: 'คำถาม', answer: 'คำตอบ', + retriever_resources: 'ทรัพยากรที่ดึงข้อมูล', response: 'การตอบกลับ', content: 'เนื้อหา', description: 'คำอธิบาย', @@ -2465,10 +2496,12 @@ const messages = { comment: 'ความคิดเห็น', model: 'โมเดล', tokens: 'โทเค็น', + tokens_used: 'โทเค็นที่ใช้', tokens_prompt: 'โทเค็นพรอมป์ต์', tokens_completion: 'โทเค็นผลลัพธ์', total_tokens: 'โทเค็นรวม', latency_ms: 'ความหน่วง (ms)', + latency: 'ความหน่วง', cost: 'ค่าใช้จ่าย', ip: 'IP', user_agent: 'User Agent', diff --git a/frontend/src/views/AdminView.vue b/frontend/src/views/AdminView.vue index 874df660..0113dded 100644 --- a/frontend/src/views/AdminView.vue +++ b/frontend/src/views/AdminView.vue @@ -1518,7 +1518,49 @@ const getColumnWidthStyle = (key: string) => { maxWidth: `${col.width}px`, }; }; -const getReportCellValue = (row: any, key: string) => row?.[key]; + +// 报表值翻译辅助:优先返回 i18n 文案;若没有配置对应翻译则回退原始值 +const getTranslatedValue = (i18nKey: string, fallbackValue: any) => { + const translated = t(i18nKey); + return translated && translated !== i18nKey ? translated : fallbackValue; +}; + +const getReportCellValue = (row: any, key: string) => { + const value = row?.[key]; + // 根据 is_active 这一列的值进行多语言翻译(布尔值兼容多种后端返回格式) + if (key === 'is_active') { + const truthy = value === true || value === 1 || value === '1' || value === 'true' || value === 'True'; + return truthy ? t('admin.status.active') : t('admin.status.disabled'); + } + + // 用户报表值翻译:角色(guest/user/admin) -> 中文角色名 + if (key === 'role' && typeof value === 'string') { + return getTranslatedValue(`admin.role.${value}`, value); + } + + // 用户报表值翻译:状态(active/disabled/pending/rejected) -> 中文状态名 + if (key === 'status' && typeof value === 'string') { + return getTranslatedValue(`admin.status.${value}`, value); + } + + // 用户报表值翻译:主题偏好(light/dark/system) -> 中文主题名 + if (key === 'theme_preference' && typeof value === 'string') { + return getTranslatedValue(`theme.${value}`, value); + } + + // 用户报表值翻译:语言(zh-CN/zh-TW/en/th) -> 语言名称 + if (key === 'language' && typeof value === 'string') { + const languageLabelMap: Record = { + 'zh-CN': '简体中文', + 'zh-TW': '繁體中文', + en: 'English', + th: 'ไทย', + }; + return languageLabelMap[value] || value; + } + + return value; +}; const normalizeSortValue = (v: any) => { if (v === null || v === undefined) return null; if (typeof v === 'number') return v; @@ -1971,13 +2013,13 @@ const handlePermissionImport = async (event: Event) => { - + --> @@ -2108,13 +2150,6 @@ const handlePermissionImport = async (event: Event) => {

{{ t('admin.approval.title') }}

{{ t('admin.approval.subtitle') }}

-
@@ -3142,7 +3177,7 @@ const handlePermissionImport = async (event: Event) => {
-

{{ t('admin.report.noData', { table: currentTable }) }}

+

{{ t('admin.report.noData', { table: getReportTableLabel(currentTable) }) }}

diff --git a/frontend/src/views/ProfileView.vue b/frontend/src/views/ProfileView.vue index 6c621468..e7a398a1 100644 --- a/frontend/src/views/ProfileView.vue +++ b/frontend/src/views/ProfileView.vue @@ -246,7 +246,9 @@ const handleChangePassword = async () => { const handleLogout = () => { localStorage.removeItem('hxops_user'); - router.push('/'); + sessionStorage.removeItem('hxops_user'); + sessionStorage.removeItem('hxops_wecom_state'); + router.replace('/'); }; onMounted(() => { diff --git a/frontend/src/views/WorkspaceView.vue b/frontend/src/views/WorkspaceView.vue index bd260090..11315677 100644 --- a/frontend/src/views/WorkspaceView.vue +++ b/frontend/src/views/WorkspaceView.vue @@ -706,8 +706,8 @@ onMounted(async () => {