feat: add comprehensive i18n support across all pages

- Add i18n support to admin sidebar, breadcrumbs, and nav-footer
- Add i18n support to admin pages: system-settings, users, versions, risk-control, sessions, cloud-variables, cloud-constants
- Add i18n support to auth pages: login, register
- Add i18n support to install and profile pages
- Add i18n support to agent pages: dashboard, finance, users, apps, cards
- Replace all hard-coded Chinese text with i18n translation keys
- Add comprehensive translation keys to zh.json and en.json
- Fix date formatting to use locale-agnostic toLocaleDateString()
- Pass t function as parameter for i18n in non-component files
This commit is contained in:
2026-05-07 23:06:58 +08:00
parent f1f2a9dc9d
commit c816f4d85c
26 changed files with 1817 additions and 658 deletions
+36 -33
View File
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { computed, onMounted, onUnmounted } from 'vue'
import { useI18n } from 'vue-i18n'
import { useRouter } from 'vue-router'
import AdminSidebar from '@/components/admin-sidebar/index.vue'
@@ -10,44 +11,46 @@ import api from '@/services/api'
import { getFileUrl } from '@/utils/config'
const router = useRouter()
const { t } = useI18n()
const breadcrumbs = computed(() => {
const path = router.currentRoute.value.path
const parts = path.split('/').filter(Boolean)
const crumbs = [{ title: '控制台', path: '/admin' }]
const crumbs = [{ title: t('nav.console'), path: '/admin' }]
const titleMap: Record<string, string> = {
applications: '应用管理',
cards: '卡密管理',
users: '用户管理',
devices: '设备管理',
sessions: '在线实例',
announcements: '公告管理',
versions: '版本管理',
'card-types': '卡类管理',
'agent-apps': '授权管理',
agents: '代理管理',
finance: '财务管理',
logs: '日志记录',
tickets: '工单系统',
'cloud-constants': '云端常量',
'cloud-variables': '云端变量',
'cloud-function': '云端函数',
'risk-control': '风控管理',
extension: '扩展配置',
profile: '个人中心',
'system-settings': '系统设置',
'payment-channels': '支付渠道',
'email-settings': '邮箱配置',
'sms-settings': '短信配置',
'storage-configs': '存储管理',
settings: '基本设置',
security: '安全设置',
create: '创建',
edit: '编辑',
recharge: '充值',
request: '申请授权',
invite: '邀请授权',
applications: t('nav.applications'),
cards: t('nav.cards'),
users: t('nav.users'),
devices: t('nav.devices'),
sessions: t('nav.sessions'),
announcements: t('nav.announcements'),
versions: t('nav.versions'),
'card-types': t('nav.cardTypes'),
'agent-apps': t('nav.agentApps'),
agents: t('nav.agents'),
finance: t('nav.finance'),
logs: t('nav.logs'),
tickets: t('nav.tickets'),
'cloud-constants': t('nav.cloudConstants'),
'cloud-variables': t('nav.cloudVariables'),
'cloud-function': t('nav.cloudFunction'),
'risk-control': t('nav.riskControl'),
extension: t('nav.extension'),
profile: t('nav.profile'),
'system-settings': t('nav.systemSettings'),
'payment-channels': t('nav.paymentChannels'),
'email-settings': t('nav.emailSettings'),
'sms-settings': t('nav.smsSettings'),
'storage-configs': t('nav.storageConfigs'),
settings: t('nav.basicSettings'),
security: t('nav.security'),
create: t('nav.create'),
edit: t('nav.edit'),
recharge: t('nav.recharge'),
request: t('nav.request'),
invite: t('nav.invite'),
records: t('nav.records'),
}
let currentPath = '/admin'
@@ -63,7 +66,7 @@ const breadcrumbs = computed(() => {
}
else if (!isNaN(Number(part)) && i === parts.length - 1) {
crumbs.push({
title: '详情',
title: t('nav.detail'),
path: currentPath,
})
}
+23 -21
View File
@@ -1,6 +1,7 @@
<script setup lang="ts">
import { Boxes, CreditCard, Gauge, Key, LogOut, User, Users } from 'lucide-vue-next'
import { computed, onMounted, reactive } from 'vue'
import { useI18n } from 'vue-i18n'
import { useRouter } from 'vue-router'
import NavTeam from '@/components/app-sidebar/nav-team.vue'
@@ -10,9 +11,10 @@ import ThemePopover from '@/components/custom-theme/theme-popover.vue'
import ToggleTheme from '@/components/toggle-theme.vue'
const router = useRouter()
const { t } = useI18n()
const user = reactive({
name: '代理商',
name: t('nav.agent'),
email: 'agent@example.com',
avatar: '/avatars/agent.jpg',
role: 'agent',
@@ -36,62 +38,62 @@ onMounted(() => {
const teams = [
{
name: '代理商后台',
name: t('nav.agentDashboard'),
logo: Users,
plan: 'Agent',
},
]
const navMain = [
const navMain = computed(() => [
{
title: '主要功能',
title: t('nav.mainFeatures'),
items: [
{
title: '控制台',
title: t('nav.console'),
url: '/agent',
icon: Gauge,
},
{
title: '应用管理',
title: t('nav.applications'),
url: '/agent/apps',
icon: Boxes,
},
{
title: '卡密管理',
title: t('nav.cards'),
url: '/agent/cards',
icon: Key,
},
{
title: '用户管理',
title: t('nav.users'),
url: '/agent/users',
icon: Users,
},
],
},
{
title: '财务',
title: t('nav.financeGroup'),
items: [
{
title: '财务管理',
title: t('nav.finance'),
url: '/agent/finance',
icon: CreditCard,
},
],
},
]
])
const breadcrumbs = computed(() => {
const path = router.currentRoute.value.path
const parts = path.split('/').filter(Boolean)
const crumbs = [{ title: '控制台', path: '/agent' }]
const crumbs = [{ title: t('nav.console'), path: '/agent' }]
const titleMap: Record<string, string> = {
apps: '应用管理',
cards: '卡密管理',
users: '用户管理',
finance: '财务管理',
profile: '个人中心',
create: '创建',
apps: t('nav.applications'),
cards: t('nav.cards'),
users: t('nav.users'),
finance: t('nav.finance'),
profile: t('nav.profile'),
create: t('nav.create'),
}
let currentPath = '/agent'
@@ -107,7 +109,7 @@ const breadcrumbs = computed(() => {
}
else if (!isNaN(Number(part))) {
crumbs.push({
title: '详情',
title: t('nav.detail'),
path: currentPath,
})
}
@@ -180,14 +182,14 @@ function handleLogout() {
<UiDropdownMenuGroup>
<UiDropdownMenuItem @click="router.push('/agent/profile')">
<User class="mr-2 h-4 w-4" />
个人中心
{{ t('nav.profile') }}
</UiDropdownMenuItem>
</UiDropdownMenuGroup>
<UiDropdownMenuSeparator />
<UiDropdownMenuItem class="text-red-500" @click="handleLogout">
<LogOut class="mr-2 h-4 w-4" />
退出登录
{{ t('nav.logout') }}
</UiDropdownMenuItem>
</UiDropdownMenuContent>
</UiDropdownMenu>