更新国际化支持:在多个对话框组件中引入 vue-i18n,优化文本翻译,确保多语言显示的一致性和准确性。

This commit is contained in:
jxxghp
2025-04-28 08:55:52 +08:00
parent daf70b6da4
commit af7aa7d47b
12 changed files with 825 additions and 148 deletions

View File

@@ -4,6 +4,10 @@ import api from '@/api'
import { useDisplay, useTheme } from 'vuetify'
import { formatFileSize } from '@/@core/utils/formatters'
import ProgressDialog from '@/components/dialog/ProgressDialog.vue'
import { useI18n } from 'vue-i18n'
// 多语言支持
const { t } = useI18n()
// 显示器宽度
const display = useDisplay()
@@ -36,11 +40,11 @@ const siteData = computed(() => siteDatas.value[siteDatas.value.length - 1])
const historySeries = computed(() => {
return [
{
name: '上传量',
name: t('dialog.siteUserData.uploadTitle'),
data: siteDatas.value.map(item => Math.round((item.upload ?? 0) / 1024 / 1024 / 1024)),
},
{
name: '下载量',
name: t('dialog.siteUserData.downloadTitle'),
data: siteDatas.value.map(item => Math.round((item.download ?? 0) / 1024 / 1024 / 1024)),
},
]
@@ -135,7 +139,7 @@ const historyChartOptions = computed(() => {
const seedingSeries = computed(() => {
return [
{
name: '体积',
name: t('dialog.siteUserData.volumeTitle'),
data: siteData.value?.seeding_info?.map(item => [item[0] ?? 0, Math.round((item[1] ?? 0) / 1024 / 1024 / 1024)]),
},
]
@@ -162,7 +166,7 @@ const seedingChartOptions = computed(() => {
enabled: true,
x: {
formatter: function (val: number) {
return '数量:' + val.toLocaleString()
return t('dialog.siteUserData.countTitle') + val.toLocaleString()
},
},
style: {
@@ -188,7 +192,7 @@ const seedingChartOptions = computed(() => {
},
},
title: {
text: '数量',
text: t('dialog.siteUserData.countTitle'),
},
tickAmount: 10,
},
@@ -282,7 +286,7 @@ onBeforeMount(async () => {
<VCard class="rounded-t">
<VCardItem>
<VCardTitle
>{{ `数据 - ${props.site?.name}` }}
>{{ t('dialog.siteUserData.title') }} - {{ props.site?.name }}
<IconBtn @click.stop="refreshSiteData" color="info"><VIcon icon="mdi-refresh" /></IconBtn>
</VCardTitle>
<VDialogCloseBtn @click="emit('close')" />
@@ -296,9 +300,9 @@ onBeforeMount(async () => {
<VCardText class="d-flex align-center">
<div class="d-flex justify-space-between" style="inline-size: 100%">
<div class="d-flex flex-column gap-y-1 overflow-hidden">
<span class="text-base">用户等级</span>
<span class="text-base">{{ t('dialog.siteUserData.userLevel') }}</span>
<h5 class="text-h5 d-flex align-center gap-2 text-wrap">
{{ siteData?.user_level || '无' }}
{{ siteData?.user_level || t('dialog.siteUserData.noData') }}
</h5>
</div>
<VAvatar variant="tonal" size="42" rounded>
@@ -314,7 +318,7 @@ onBeforeMount(async () => {
<VCardText class="d-flex align-center">
<div class="d-flex justify-space-between" style="inline-size: 100%">
<div class="d-flex flex-column gap-y-1 overflow-hidden">
<span class="text-base">积分</span>
<span class="text-base">{{ t('dialog.siteUserData.bonus') }}</span>
<h5 class="text-h5 d-flex align-center gap-2 text-wrap">
{{ siteData?.bonus?.toLocaleString() }}
<span class="text-base font-weight-regular" :class="getDiffClass(diffData?.bonus)">
@@ -335,7 +339,7 @@ onBeforeMount(async () => {
<VCardText class="d-flex align-center">
<div class="d-flex justify-space-between" style="inline-size: 100%">
<div class="d-flex flex-column gap-y-1">
<span class="text-base">分享率</span>
<span class="text-base">{{ t('dialog.siteUserData.ratio') }}</span>
<h5 class="text-h5 d-flex align-center gap-2 text-wrap">
{{ siteData?.ratio }}
<span class="text-base font-weight-regular" :class="getDiffClass(diffData?.ratio)">
@@ -356,7 +360,7 @@ onBeforeMount(async () => {
<VCardText class="d-flex align-center">
<div class="d-flex justify-space-between" style="inline-size: 100%">
<div class="d-flex flex-column gap-y-1 overflow-hidden">
<span class="text-base">总上传量</span>
<span class="text-base">{{ t('dialog.siteUserData.uploadTotal') }}</span>
<h5 class="text-h5 d-flex align-center gap-2 text-wrap">
{{ formatFileSize(siteData?.upload || 0) }}
<span class="text-base font-weight-regular" :class="getDiffClass(diffData?.upload)">
@@ -377,7 +381,7 @@ onBeforeMount(async () => {
<VCardText class="d-flex align-center">
<div class="d-flex justify-space-between" style="inline-size: 100%">
<div class="d-flex flex-column gap-y-1 overflow-hidden">
<span class="text-base">总下载量</span>
<span class="text-base">{{ t('dialog.siteUserData.downloadTotal') }}</span>
<h5 class="text-h5 d-flex align-center gap-2 text-wrap">
{{ formatFileSize(siteData?.download || 0) }}
<span class="text-base font-weight-regular" :class="getDiffClass(diffData?.download)">
@@ -398,7 +402,7 @@ onBeforeMount(async () => {
<VCardText class="d-flex align-center">
<div class="d-flex justify-space-between" style="inline-size: 100%">
<div class="d-flex flex-column gap-y-1 overflow-hidden">
<span class="text-base">总做种数</span>
<span class="text-base">{{ t('dialog.siteUserData.seedingCount') }}</span>
<h5 class="text-h5 d-flex align-center gap-2 text-wrap">
{{ siteData?.seeding?.toLocaleString() }}
<span class="text-base font-weight-regular" :class="getDiffClass(diffData?.seeding)">
@@ -419,7 +423,7 @@ onBeforeMount(async () => {
<VCardText class="d-flex align-center">
<div class="d-flex justify-space-between" style="inline-size: 100%">
<div class="d-flex flex-column gap-y-1 overflow-hidden">
<span class="text-base">总做种体积</span>
<span class="text-base">{{ t('dialog.siteUserData.seedingSize') }}</span>
<h5 class="text-h5 d-flex align-center gap-2 text-wrap">
{{ formatFileSize(siteData?.seeding_size || 0) }}
<span class="text-base font-weight-regular" :class="getDiffClass(diffData?.seeding_size)">
@@ -440,7 +444,7 @@ onBeforeMount(async () => {
<VCardText class="d-flex align-center">
<div class="d-flex justify-space-between" style="inline-size: 100%">
<div class="d-flex flex-column gap-y-1 overflow-hidden">
<span class="text-base">加入时间</span>
<span class="text-base">{{ t('dialog.siteUserData.joinTime') }}</span>
<h5 class="text-h5 d-flex align-center gap-2 text-wrap">
{{ siteData?.join_at?.split(' ')[0] }}
</h5>
@@ -455,7 +459,7 @@ onBeforeMount(async () => {
</VRow>
<VRow>
<VCol>
<VCard title="历史流量">
<VCard :title="t('dialog.siteUserData.trafficHistory')">
<VCardText>
<VApexChart type="line" :options="historyChartOptions" :series="historySeries" :height="300" />
</VCardText>
@@ -464,7 +468,7 @@ onBeforeMount(async () => {
</VRow>
<VRow>
<VCol>
<VCard title="做种分布">
<VCard :title="t('dialog.siteUserData.seedingDistribution')">
<VCardText>
<VApexChart type="scatter" :options="seedingChartOptions" :series="seedingSeries" :height="300" />
</VCardText>
@@ -474,6 +478,6 @@ onBeforeMount(async () => {
</VCardText>
</VCard>
<!-- 进度框 -->
<ProgressDialog v-if="progressDialog" v-model="progressDialog" text="正在刷新站点数据..." />
<ProgressDialog v-if="progressDialog" v-model="progressDialog" :text="t('dialog.siteUserData.refreshing')" />
</VDialog>
</template>