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:
@@ -1,26 +1,29 @@
|
||||
<script lang="ts" setup>
|
||||
import { Boxes, Code, CreditCard, DollarSign, FileLock, Gauge, GitBranch, HardDrive, Hash, Key, Mail, Megaphone, MessageSquare, Monitor, Network, Plug, ScrollText, Settings, Shield, Smartphone, Users, Variable, Share2 } from 'lucide-vue-next'
|
||||
import { onMounted, onUnmounted, reactive } from 'vue'
|
||||
import { computed, onMounted, onUnmounted, reactive } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
import NavTeam from '@/components/app-sidebar/nav-team.vue'
|
||||
import TeamSwitcher from '@/components/app-sidebar/team-switcher.vue'
|
||||
import NavFooter from '@/components/admin-sidebar/nav-footer.vue'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const user = reactive({
|
||||
name: '管理员',
|
||||
name: t('nav.admin'),
|
||||
email: 'admin@example.com',
|
||||
avatar: '/avatars/admin.jpg',
|
||||
role: 'admin',
|
||||
})
|
||||
|
||||
const siteSettings = reactive({
|
||||
name: '管理后台',
|
||||
name: t('nav.adminDashboard'),
|
||||
logo: '',
|
||||
})
|
||||
|
||||
const teams = reactive([
|
||||
{
|
||||
name: '管理后台',
|
||||
name: t('nav.adminDashboard'),
|
||||
logo: Code,
|
||||
},
|
||||
])
|
||||
@@ -80,148 +83,148 @@ onUnmounted(() => {
|
||||
window.removeEventListener('system-settings-changed', handleSettingsChange as EventListener)
|
||||
})
|
||||
|
||||
const navMain = [
|
||||
const navMain = computed(() => [
|
||||
{
|
||||
title: '主要功能',
|
||||
title: t('nav.mainFeatures'),
|
||||
items: [
|
||||
{
|
||||
title: '控制台',
|
||||
title: t('nav.console'),
|
||||
url: '/admin',
|
||||
icon: Gauge,
|
||||
},
|
||||
{
|
||||
title: '应用管理',
|
||||
title: t('nav.applications'),
|
||||
url: '/admin/applications',
|
||||
icon: Boxes,
|
||||
},
|
||||
{
|
||||
title: '卡类管理',
|
||||
title: t('nav.cardTypes'),
|
||||
url: '/admin/card-types',
|
||||
icon: Hash,
|
||||
},
|
||||
{
|
||||
title: '卡密管理',
|
||||
title: t('nav.cards'),
|
||||
url: '/admin/cards',
|
||||
icon: Key,
|
||||
},
|
||||
{
|
||||
title: '公告管理',
|
||||
title: t('nav.announcements'),
|
||||
url: '/admin/announcements',
|
||||
icon: Megaphone,
|
||||
},
|
||||
{
|
||||
title: '版本管理',
|
||||
title: t('nav.versions'),
|
||||
url: '/admin/versions',
|
||||
icon: GitBranch,
|
||||
},
|
||||
{
|
||||
title: '用户管理',
|
||||
title: t('nav.users'),
|
||||
url: '/admin/users',
|
||||
icon: Users,
|
||||
},
|
||||
{
|
||||
title: '设备管理',
|
||||
title: t('nav.devices'),
|
||||
url: '/admin/devices',
|
||||
icon: Smartphone,
|
||||
},
|
||||
{
|
||||
title: '在线实例',
|
||||
title: t('nav.sessions'),
|
||||
url: '/admin/sessions',
|
||||
icon: Monitor,
|
||||
},
|
||||
{
|
||||
title: '代理管理',
|
||||
title: t('nav.agents'),
|
||||
url: '/admin/agents',
|
||||
icon: Network,
|
||||
},
|
||||
{
|
||||
title: '授权管理',
|
||||
title: t('nav.agentApps'),
|
||||
url: '/admin/agent-apps',
|
||||
icon: Share2,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '业务管理',
|
||||
title: t('nav.businessManagement'),
|
||||
items: [
|
||||
{
|
||||
title: '财务管理',
|
||||
title: t('nav.finance'),
|
||||
url: '/admin/finance',
|
||||
icon: DollarSign,
|
||||
},
|
||||
{
|
||||
title: '日志记录',
|
||||
title: t('nav.logs'),
|
||||
url: '/admin/logs',
|
||||
icon: ScrollText,
|
||||
},
|
||||
{
|
||||
title: '工单系统',
|
||||
title: t('nav.tickets'),
|
||||
url: '/admin/tickets',
|
||||
icon: MessageSquare,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '高级功能',
|
||||
title: t('nav.advancedFeatures'),
|
||||
items: [
|
||||
{
|
||||
title: '云端常量',
|
||||
title: t('nav.cloudConstants'),
|
||||
url: '/admin/cloud-constants',
|
||||
icon: FileLock,
|
||||
},
|
||||
{
|
||||
title: '云端变量',
|
||||
title: t('nav.cloudVariables'),
|
||||
url: '/admin/cloud-variables',
|
||||
icon: Variable,
|
||||
},
|
||||
{
|
||||
title: '云端函数',
|
||||
title: t('nav.cloudFunction'),
|
||||
url: '/admin/cloud-function',
|
||||
icon: Code,
|
||||
},
|
||||
{
|
||||
title: '风控管理',
|
||||
title: t('nav.riskControl'),
|
||||
url: '/admin/risk-control',
|
||||
icon: Shield,
|
||||
},
|
||||
{
|
||||
title: '扩展配置',
|
||||
title: t('nav.extension'),
|
||||
url: '/admin/extension',
|
||||
icon: Plug,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '系统管理',
|
||||
title: t('nav.systemManagement'),
|
||||
items: [
|
||||
{
|
||||
title: '系统设置',
|
||||
title: t('nav.systemSettings'),
|
||||
url: '/admin/system-settings',
|
||||
icon: Settings,
|
||||
},
|
||||
{
|
||||
title: '支付渠道',
|
||||
title: t('nav.paymentChannels'),
|
||||
url: '/admin/payment-channels',
|
||||
icon: CreditCard,
|
||||
},
|
||||
{
|
||||
title: '邮箱配置',
|
||||
title: t('nav.emailSettings'),
|
||||
url: '/admin/email-settings',
|
||||
icon: Mail,
|
||||
},
|
||||
{
|
||||
title: '短信配置',
|
||||
title: t('nav.smsSettings'),
|
||||
url: '/admin/sms-settings',
|
||||
icon: Smartphone,
|
||||
},
|
||||
{
|
||||
title: '存储管理',
|
||||
title: t('nav.storageConfigs'),
|
||||
url: '/admin/storage-configs',
|
||||
icon: HardDrive,
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { Crown, ChevronsUpDown, Database, LogOut, Ticket, UserRoundCog, Zap } from 'lucide-vue-next'
|
||||
import { ref } from 'vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { useRouter } from 'vue-router'
|
||||
|
||||
import type { User } from '@/components/app-sidebar/types'
|
||||
@@ -8,14 +9,15 @@ import type { User } from '@/components/app-sidebar/types'
|
||||
import { useSidebar } from '@/components/ui/sidebar'
|
||||
|
||||
const router = useRouter()
|
||||
const { t } = useI18n()
|
||||
|
||||
const props = defineProps<{ user: User }>()
|
||||
|
||||
const { isMobile, open } = useSidebar()
|
||||
|
||||
const subscription = ref({
|
||||
plan: '基础版',
|
||||
status: '正常',
|
||||
plan: t('nav.basicPlan'),
|
||||
status: t('nav.normal'),
|
||||
apiQuota: 10000,
|
||||
apiUsed: 0,
|
||||
storageQuota: 100 * 1024 * 1024,
|
||||
@@ -52,8 +54,8 @@ function handleLogout() {
|
||||
<span class="text-xs font-medium">{{ subscription.plan }}</span>
|
||||
</div>
|
||||
<UiBadge
|
||||
:variant="subscription.status === '正常' ? 'default' : 'secondary'"
|
||||
:class="subscription.status === '正常' ? 'bg-green-500/10 text-green-500' : ''"
|
||||
:variant="subscription.status === t('nav.normal') ? 'default' : 'secondary'"
|
||||
:class="subscription.status === t('nav.normal') ? 'bg-green-500/10 text-green-500' : ''"
|
||||
class="text-[10px]"
|
||||
>
|
||||
{{ subscription.status }}
|
||||
@@ -80,7 +82,7 @@ function handleLogout() {
|
||||
<div class="flex items-center justify-between text-[10px]">
|
||||
<span class="text-muted-foreground flex items-center space-x-1">
|
||||
<Database class="size-3" />
|
||||
<span>存储</span>
|
||||
<span>{{ t('nav.storage') }}</span>
|
||||
</span>
|
||||
<span class="font-medium">{{ formatStorage(subscription.storageUsed) }} / {{ formatStorage(subscription.storageQuota) }}</span>
|
||||
</div>
|
||||
@@ -140,18 +142,18 @@ function handleLogout() {
|
||||
<UiDropdownMenuGroup>
|
||||
<UiDropdownMenuItem @click="router.push('/admin/profile')">
|
||||
<UserRoundCog class="mr-2 h-4 w-4" />
|
||||
个人中心
|
||||
{{ t('nav.profile') }}
|
||||
</UiDropdownMenuItem>
|
||||
<UiDropdownMenuItem @click="router.push('/admin/tickets')">
|
||||
<Ticket class="mr-2 h-4 w-4" />
|
||||
工单系统
|
||||
{{ t('nav.tickets') }}
|
||||
</UiDropdownMenuItem>
|
||||
</UiDropdownMenuGroup>
|
||||
|
||||
<UiDropdownMenuSeparator />
|
||||
<UiDropdownMenuItem class="text-red-500" @click="handleLogout">
|
||||
<LogOut class="mr-2 h-4 w-4" />
|
||||
退出登录
|
||||
{{ t('nav.logout') }}
|
||||
</UiDropdownMenuItem>
|
||||
</UiDropdownMenuContent>
|
||||
</UiDropdownMenu>
|
||||
|
||||
Reference in New Issue
Block a user