fix: fix serveral bugs of frontend

This commit is contained in:
sophie committed 2026-04-09 13:41:22 +08:00
1 parent 482d2d73a3
commit 45ed2ed72a
4 files changed
+102 -21

No files matched your search

+37 -4
View File
@@ -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',
+46 -11
View File
@@ -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<string, string> = {
'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) => {
</select>
</div>
<button
<!-- <button
@click="saveConfig"
class="hidden md:flex items-center gap-2 px-5 py-2.5 bg-slate-900 dark:bg-slate-700 text-white rounded-xl hover:bg-slate-800 dark:hover:bg-slate-600 transition-all shadow-lg shadow-slate-200 active:scale-95"
>
<Save class="w-4 h-4" />
<span class="font-medium text-sm">{{ t('admin.save') }}</span>
</button>
</button> -->
</div>
</header>
@@ -2108,13 +2150,6 @@ const handlePermissionImport = async (event: Event) => {
<h2 class="text-lg font-bold text-slate-900">{{ t('admin.approval.title') }}</h2>
<p class="text-sm text-slate-500 mt-1">{{ t('admin.approval.subtitle') }}</p>
</div>
<button
@click="openCreateUserModal"
class="flex items-center gap-2 px-4 py-2 bg-brand-600 text-white rounded-xl hover:bg-brand-700 transition-all shadow-lg shadow-brand-200 active:scale-95 text-sm font-medium"
>
<Plus class="w-4 h-4" />
<span class="font-medium">{{ t('admin.approval.addUser') }}</span>
</button>
</div>
<div class="overflow-x-auto">
<table class="w-full">
@@ -3142,7 +3177,7 @@ const handlePermissionImport = async (event: Event) => {
</div>
<div v-if="tableData.length === 0" class="text-center text-slate-400 py-20 bg-slate-50 rounded-2xl border border-dashed border-slate-300">
<p>{{ t('admin.report.noData', { table: currentTable }) }}</p>
<p>{{ t('admin.report.noData', { table: getReportTableLabel(currentTable) }) }}</p>
</div>
<div v-else class="overflow-x-auto rounded-2xl border border-slate-200 bg-white shadow-[0_12px_40px_-28px_rgba(15,23,42,0.5)]">
+3 -1
View File
@@ -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(() => {
+16 -5
View File
@@ -706,8 +706,8 @@ onMounted(async () => {
<template>
<div class="min-h-screen bg-gray-50 dark:bg-slate-950 font-sans text-slate-800 dark:text-slate-200">
<!-- Top Right Controls -->
<div class="fixed top-4 right-4 z-50 flex items-center gap-2">
<!-- 右上角全局控件:仅未登录页固定显示,避免与已登录头部区域重叠 -->
<div v-if="!isLoggedIn" class="fixed top-4 right-4 z-50 flex items-center gap-2">
<ThemeToggleButton />
<select v-model="locale" class="bg-white/80 dark:bg-slate-900/80 backdrop-blur-md shadow-sm border border-slate-200 dark:border-slate-700 text-xs font-medium text-slate-600 dark:text-slate-300 hover:text-slate-800 dark:hover:text-slate-100 cursor-pointer outline-none rounded-full px-3 py-1.5 transition-all hover:shadow-md">
<option value="en">English</option>
@@ -733,6 +733,16 @@ onMounted(async () => {
</div>
<div class="flex items-center gap-4">
<!-- 已登录页将主题与语言切换放入头部右侧,避免不同分辨率下被遮挡 -->
<div class="flex items-center gap-2">
<ThemeToggleButton />
<select v-model="locale" class="bg-white/80 dark:bg-slate-900/80 backdrop-blur-md shadow-sm border border-slate-200 dark:border-slate-700 text-xs font-medium text-slate-600 dark:text-slate-300 hover:text-slate-800 dark:hover:text-slate-100 cursor-pointer outline-none rounded-full px-3 py-1.5 transition-all hover:shadow-md">
<option value="en">English</option>
<option value="zh-CN">简体中文</option>
<option value="zh-TW">繁體中文</option>
<option value="th">ไทย</option>
</select>
</div>
<!-- User Profile Dropdown -->
<div class="relative">
<button @click="showUserDropdown = !showUserDropdown" class="flex items-center gap-3 pl-3 pr-2 py-1.5 rounded-full hover:bg-slate-50 dark:hover:bg-slate-800 transition-colors border border-transparent hover:border-slate-200 dark:hover:border-slate-700">
@@ -787,7 +797,7 @@ onMounted(async () => {
</div>
<!-- Not Logged In (Login Screen) -->
<div v-else-if="!isLoggedIn" class="min-h-[calc(100vh-4rem)] flex items-center justify-center -mt-16 md:-mt-20">
<div v-else-if="!isLoggedIn" class="min-h-[calc(100vh-4rem)] flex items-center justify-center">
<div class="w-full max-w-6xl grid grid-cols-1 lg:grid-cols-2 gap-12 items-center p-4">
<!-- Hero Section -->
<div class="hidden lg:block space-y-8 animate-slide-up">
@@ -887,9 +897,10 @@ onMounted(async () => {
<button @click="showForgotPasswordModal = true" class="text-sm text-slate-500 hover:text-brand-600 transition-colors">
{{ $t('login.forgotPassword') }}
</button>
<button @click="showRegisterModal = true" class="text-sm font-semibold text-brand-600 hover:text-brand-700 hover:underline transition-colors">
<!-- 点击注册 -->
<!-- <button @click="showRegisterModal = true" class="text-sm font-semibold text-brand-600 hover:text-brand-700 hover:underline transition-colors">
{{ $t('login.registerLink') }}
</button>
</button> -->
</div>
</div>