mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-14 10:56:37 +08:00
feat(frontend): 控制台 next-intl 中英双语
接入无 URL 前缀的 zh-CN/en,顶栏与外观设置可切换语言;选择写入 cookie 后刷新生效。
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { useTranslations } from 'next-intl';
|
||||
|
||||
import { RankChart } from '@/components/data/rank-chart';
|
||||
import {
|
||||
Card,
|
||||
@@ -25,19 +27,20 @@ export function SourceDistributionChart({
|
||||
}: {
|
||||
items: TrafficDistributions['source_countries'];
|
||||
}) {
|
||||
const t = useTranslations('dashboard.distributions');
|
||||
return (
|
||||
<Card className='border-dashed shadow-none'>
|
||||
<CardHeader>
|
||||
<CardTitle className='text-sm font-semibold'>来源分布</CardTitle>
|
||||
<CardDescription className='text-xs'>
|
||||
聚合最近 24 小时主要来源国家。
|
||||
</CardDescription>
|
||||
<CardTitle className='text-sm font-semibold'>
|
||||
{t('sourceTitle')}
|
||||
</CardTitle>
|
||||
<CardDescription className='text-xs'>{t('sourceDesc')}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<RankChart
|
||||
items={toRankItems(items)}
|
||||
color='#38bdf8'
|
||||
emptyMessage='暂无来源分布数据'
|
||||
emptyMessage={t('sourceEmpty')}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -49,22 +52,23 @@ export function StatusCodeDistributionChart({
|
||||
}: {
|
||||
items: TrafficDistributions['status_codes'];
|
||||
}) {
|
||||
const t = useTranslations('dashboard.distributions');
|
||||
return (
|
||||
<Card className='border-dashed shadow-none'>
|
||||
<CardHeader>
|
||||
<CardTitle className='text-sm font-semibold'>状态码分布</CardTitle>
|
||||
<CardDescription className='text-xs'>
|
||||
快速判断成功响应是否仍是主流,以及错误码是否有抬升。
|
||||
</CardDescription>
|
||||
<CardTitle className='text-sm font-semibold'>
|
||||
{t('statusTitle')}
|
||||
</CardTitle>
|
||||
<CardDescription className='text-xs'>{t('statusDesc')}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<RankChart
|
||||
items={toRankItems(items).map((item) => ({
|
||||
...item,
|
||||
label: `HTTP ${item.label}`,
|
||||
label: t('httpLabel', { code: item.label }),
|
||||
}))}
|
||||
color='#f59e0b'
|
||||
emptyMessage='暂无状态码分布'
|
||||
emptyMessage={t('statusEmpty')}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -76,19 +80,20 @@ export function TopDomainChart({
|
||||
}: {
|
||||
items: TrafficDistributions['top_domains'];
|
||||
}) {
|
||||
const t = useTranslations('dashboard.distributions');
|
||||
return (
|
||||
<Card className='border-dashed shadow-none'>
|
||||
<CardHeader>
|
||||
<CardTitle className='text-sm font-semibold'>Top Domain</CardTitle>
|
||||
<CardDescription className='text-xs'>
|
||||
观察主要流量集中在哪些域名。
|
||||
</CardDescription>
|
||||
<CardTitle className='text-sm font-semibold'>
|
||||
{t('domainTitle')}
|
||||
</CardTitle>
|
||||
<CardDescription className='text-xs'>{t('domainDesc')}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<RankChart
|
||||
items={toRankItems(items)}
|
||||
color='#34d399'
|
||||
emptyMessage='暂无域名分布'
|
||||
emptyMessage={t('domainEmpty')}
|
||||
/>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user