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
+14 -11
View File
@@ -1,9 +1,12 @@
<script setup lang="ts">
import { ArrowDownLeft, ArrowUpRight, Loader2, Receipt, RotateCcw } from 'lucide-vue-next'
import { onMounted, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import api from '@/services/api'
const { t } = useI18n()
interface Transaction {
id: number
type: string
@@ -24,7 +27,7 @@ onMounted(async () => {
transactions.value = data?.transactions || []
}
catch (error) {
console.error('获取财务数据失败:', error)
console.error('Load finance data failed:', error)
}
finally {
loading.value = false
@@ -32,14 +35,14 @@ onMounted(async () => {
})
function formatDate(dateStr: string) {
return new Date(dateStr).toLocaleString('zh-CN')
return new Date(dateStr).toLocaleString()
}
function getTypeLabel(type: string) {
const map: Record<string, string> = {
recharge: '充值',
consume: '消费',
refund: '退款',
recharge: t('agent.finance.recharge'),
consume: t('agent.finance.consume'),
refund: t('agent.finance.refund'),
}
return map[type] || type
}
@@ -58,10 +61,10 @@ function getTypeClass(type: string) {
<div class="space-y-6">
<div>
<h1 class="text-2xl font-bold">
财务管理
{{ t('agent.finance.title') }}
</h1>
<p class="text-muted-foreground">
查看您的账户余额和交易记录
{{ t('agent.finance.description') }}
</p>
</div>
@@ -69,7 +72,7 @@ function getTypeClass(type: string) {
<UiCard>
<UiCardHeader class="pb-2">
<UiCardTitle class="text-sm font-medium">
账户余额
{{ t('agent.finance.accountBalance') }}
</UiCardTitle>
</UiCardHeader>
<UiCardContent>
@@ -82,7 +85,7 @@ function getTypeClass(type: string) {
<UiCard>
<UiCardHeader>
<UiCardTitle>交易记录</UiCardTitle>
<UiCardTitle>{{ t('agent.finance.transactionRecords') }}</UiCardTitle>
</UiCardHeader>
<UiCardContent class="p-0">
<div v-if="loading" class="flex items-center justify-center py-12">
@@ -91,7 +94,7 @@ function getTypeClass(type: string) {
<div v-else-if="transactions.length === 0" class="text-center py-12 text-muted-foreground">
<Receipt class="size-16 mx-auto mb-4 opacity-30" />
<p>暂无交易记录</p>
<p>{{ t('agent.finance.noTransactions') }}</p>
</div>
<div v-else class="divide-y">
@@ -125,7 +128,7 @@ function getTypeClass(type: string) {
{{ tx.type === 'recharge' || tx.type === 'refund' ? '+' : '-' }}¥{{ tx.amount.toFixed(2) }}
</p>
<p class="text-xs text-muted-foreground">
余额: ¥{{ tx.balance.toFixed(2) }}
{{ t('agent.finance.balance') }}: ¥{{ tx.balance.toFixed(2) }}
</p>
</div>
</div>