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
+20 -17
View File
@@ -1,9 +1,12 @@
<script setup lang="ts">
import { Key, Loader2, Plus } from 'lucide-vue-next'
import { onMounted, ref } from 'vue'
import { useI18n } from 'vue-i18n'
import api from '@/services/api'
const { t } = useI18n()
interface Card {
id: number
code: string
@@ -23,7 +26,7 @@ onMounted(async () => {
cards.value = data || []
}
catch (error) {
console.error('获取卡密列表失败:', error)
console.error('Load cards failed:', error)
}
finally {
loading.value = false
@@ -33,15 +36,15 @@ onMounted(async () => {
function formatDate(dateStr: string | null) {
if (!dateStr)
return '-'
return new Date(dateStr).toLocaleDateString('zh-CN')
return new Date(dateStr).toLocaleDateString()
}
function getStatusBadge(status: string) {
const map: Record<string, { label: string, class: string }> = {
unused: { label: '未使用', class: 'bg-green-500/10 text-green-500' },
used: { label: '已使用', class: 'bg-blue-500/10 text-blue-500' },
expired: { label: '已过期', class: 'bg-red-500/10 text-red-500' },
disabled: { label: '已禁用', class: 'bg-gray-500/10 text-gray-500' },
unused: { label: t('agent.cards.unused'), class: 'bg-green-500/10 text-green-500' },
used: { label: t('agent.cards.used'), class: 'bg-blue-500/10 text-blue-500' },
expired: { label: t('agent.cards.expired'), class: 'bg-red-500/10 text-red-500' },
disabled: { label: t('agent.cards.disabled'), class: 'bg-gray-500/10 text-gray-500' },
}
return map[status] || { label: status, class: '' }
}
@@ -52,16 +55,16 @@ function getStatusBadge(status: string) {
<div class="flex items-center justify-between">
<div>
<h1 class="text-2xl font-bold">
卡密管理
{{ t('agent.cards.title') }}
</h1>
<p class="text-muted-foreground">
管理您生成的卡密
{{ t('agent.cards.description') }}
</p>
</div>
<UiButton as-child>
<router-link to="/agent/cards/create">
<Plus class="mr-2 h-4 w-4" />
生成卡密
{{ t('agent.cards.generateCards') }}
</router-link>
</UiButton>
</div>
@@ -74,10 +77,10 @@ function getStatusBadge(status: string) {
<div v-else-if="cards.length === 0" class="text-center py-12 text-muted-foreground">
<Key class="size-16 mx-auto mb-4 opacity-30" />
<p>暂无卡密记录</p>
<p>{{ t('agent.cards.noCards') }}</p>
<UiButton class="mt-4" as-child>
<router-link to="/agent/cards/create">
生成卡密
{{ t('agent.cards.generateCards') }}
</router-link>
</UiButton>
</div>
@@ -87,22 +90,22 @@ function getStatusBadge(status: string) {
<thead class="bg-muted/50">
<tr>
<th class="px-4 py-3 text-left text-sm font-medium">
卡密
{{ t('agent.cards.cardCode') }}
</th>
<th class="px-4 py-3 text-left text-sm font-medium">
应用
{{ t('agent.cards.app') }}
</th>
<th class="px-4 py-3 text-left text-sm font-medium">
卡类
{{ t('agent.cards.cardType') }}
</th>
<th class="px-4 py-3 text-left text-sm font-medium">
状态
{{ t('agent.cards.status') }}
</th>
<th class="px-4 py-3 text-left text-sm font-medium">
创建时间
{{ t('agent.cards.createTime') }}
</th>
<th class="px-4 py-3 text-left text-sm font-medium">
使用时间
{{ t('agent.cards.useTime') }}
</th>
</tr>
</thead>