优化多语言翻译

This commit is contained in:
2026-03-20 10:29:31 +08:00
parent b689a40595
commit 6ff65afcb5
19 changed files with 768 additions and 279 deletions

View File

@@ -1,78 +1,76 @@
<template>
<el-dialog
v-model="visible"
title="权重配比"
:title="$t('page.weightRatio.title')"
width="900px"
align-center
:close-on-click-modal="false"
@close="handleClose"
>
<div class="global-tip">
配置<strong>奖励对照表dice_reward</strong>的权重一级按<strong>方向</strong>顺时针/逆时针二级按<strong>档位</strong>T1-T5各条权重
1-10000档位内按权重比抽取
{{ $t('page.weightRatio.globalTip') }}
</div>
<div v-loading="loading" class="dialog-body">
<!-- 一级方向懒加载避免逆时针柱状图在隐藏容器内初始化导致不显示二级档位 -->
<el-tabs v-model="activeDirection" type="card" class="direction-tabs" :lazy="true">
<el-tab-pane label="顺时针" name="0">
<el-tab-pane :label="$t('page.weightRatio.tabClockwise')" name="0">
<el-tabs v-model="activeTier" type="card" class="tier-tabs">
<el-tab-pane v-for="t in tierKeys" :key="'cw-' + t" :label="t" :name="t">
<div v-if="getTierItems(t).length === 0" class="empty-tip">该档位暂无配置数据</div>
<div v-if="getTierItems(t).length === 0" class="empty-tip">{{ $t('page.weightShared.emptyTier') }}</div>
<template v-else>
<div class="chart-wrap" v-if="t !== 'T4' && t !== 'T5'">
<ArtBarChart
:key="'cw-' + activeDirection + '-' + t"
x-axis-name="点数"
:x-axis-name="$t('page.weightShared.xAxisGridNumber')"
:x-axis-data="getTierChartLabels(t)"
:data="getTierChartDataForCurrentDirection(t)"
height="180px"
/>
</div>
<div class="weight-sum" v-if="t !== 'T4' && t !== 'T5'">
当前档位权重合计<strong>{{ getTierSumForCurrentDirection(t) }}</strong>
各条 1-10000档位内按权重比抽取和不限制
{{
$t('page.weightShared.sumLineSingle', { sum: getTierSumForCurrentDirection(t) })
}}
</div>
<div class="weight-sum weight-sum-t4t5" v-else
>T4T5 仅单一结果无需配置权重</div
>
<div class="weight-sum weight-sum-t4t5" v-else>{{ $t('page.weightShared.t4t5NoteSingle') }}</div>
<el-table :data="getTierItems(t)" border size="small" class="weight-table">
<el-table-column
label="点数(grid_number)"
:label="$t('page.weightShared.colGridNumber')"
prop="grid_number"
width="110"
align="center"
show-overflow-tooltip
/>
<el-table-column
label="结束索引(id)"
:label="$t('page.weightShared.colEndIndexId')"
prop="id"
width="90"
align="center"
show-overflow-tooltip
/>
<el-table-column
label="实际中奖金额"
:label="$t('page.weightShared.colRealEv')"
prop="real_ev"
width="90"
align="center"
show-overflow-tooltip
/>
<el-table-column
label="显示文本"
:label="$t('page.weightShared.colUiText')"
prop="ui_text"
min-width="70"
align="center"
show-overflow-tooltip
/>
<el-table-column
label="备注"
:label="$t('page.weightShared.colRemark')"
prop="remark"
min-width="70"
align="center"
show-overflow-tooltip
/>
<el-table-column
:label="currentDirectionLabel + ' 权重(1-10000)'"
:label="currentWeightColumnLabel"
min-width="200"
align="center"
>
@@ -156,65 +154,64 @@
</el-tab-pane>
</el-tabs>
</el-tab-pane>
<el-tab-pane label="逆时针" name="1">
<el-tab-pane :label="$t('page.weightRatio.tabCounterclockwise')" name="1">
<el-tabs v-model="activeTier" type="card" class="tier-tabs">
<el-tab-pane v-for="t in tierKeys" :key="'ccw-' + t" :label="t" :name="t">
<div v-if="getTierItems(t).length === 0" class="empty-tip">该档位暂无配置数据</div>
<div v-if="getTierItems(t).length === 0" class="empty-tip">{{ $t('page.weightShared.emptyTier') }}</div>
<template v-else>
<div class="chart-wrap" v-if="t !== 'T4' && t !== 'T5'">
<ArtBarChart
:key="'ccw-' + activeDirection + '-' + t"
x-axis-name="点数"
:x-axis-name="$t('page.weightShared.xAxisGridNumber')"
:x-axis-data="getTierChartLabels(t)"
:data="getTierChartDataForCurrentDirection(t)"
height="180px"
/>
</div>
<div class="weight-sum" v-if="t !== 'T4' && t !== 'T5'">
当前档位权重合计:<strong>{{ getTierSumForCurrentDirection(t) }}</strong>
(各条 1-10000档位内按权重比抽取和不限制
{{
$t('page.weightShared.sumLineSingle', { sum: getTierSumForCurrentDirection(t) })
}}
</div>
<div class="weight-sum weight-sum-t4t5" v-else
>T4、T5 仅单一结果,无需配置权重。</div
>
<div class="weight-sum weight-sum-t4t5" v-else>{{ $t('page.weightShared.t4t5NoteSingle') }}</div>
<el-table :data="getTierItems(t)" border size="small" class="weight-table">
<el-table-column
label="点数(grid_number)"
:label="$t('page.weightShared.colGridNumber')"
prop="grid_number"
width="110"
align="center"
show-overflow-tooltip
/>
<el-table-column
label="结束索引(id)"
:label="$t('page.weightShared.colEndIndexId')"
prop="id"
width="90"
align="center"
show-overflow-tooltip
/>
<el-table-column
label="实际中奖金额"
:label="$t('page.weightShared.colRealEv')"
prop="real_ev"
width="90"
align="center"
show-overflow-tooltip
/>
<el-table-column
label="显示文本"
:label="$t('page.weightShared.colUiText')"
prop="ui_text"
min-width="70"
align="center"
show-overflow-tooltip
/>
<el-table-column
label="备注"
:label="$t('page.weightShared.colRemark')"
prop="remark"
min-width="70"
align="center"
show-overflow-tooltip
/>
<el-table-column
:label="currentDirectionLabel + ' 权重(1-10000)'"
:label="currentWeightColumnLabel"
min-width="200"
align="center"
>
@@ -301,13 +298,14 @@
</el-tabs>
</div>
<template #footer>
<el-button @click="handleClose">取消</el-button>
<el-button @click="handleClose">{{ $t('page.weightShared.btnCancel') }}</el-button>
<el-button
v-permission="'dice:reward:index:batchUpdateWeights'"
type="primary"
:loading="submitting"
@click="handleSubmit"
>提交</el-button>
>{{ $t('page.weightShared.btnSubmit') }}</el-button
>
</template>
</el-dialog>
</template>
@@ -316,6 +314,9 @@
import api from '../../../api/reward/index'
import ArtBarChart from '@/components/core/charts/art-bar-chart/index.vue'
import { ElMessage } from 'element-plus'
import { useI18n } from 'vue-i18n'
const { t, locale } = useI18n()
const TIER_KEYS = ['T1', 'T2', 'T3', 'T4', 'T5'] as const
type DirectionKey = 'clockwise' | 'counterclockwise'
@@ -366,9 +367,14 @@
T5: { '0': [], '1': [] }
})
const currentDirectionLabel = computed(() =>
activeDirection.value === '0' ? '顺时针' : '逆时针'
)
const currentWeightColumnLabel = computed(() => {
locale.value
const dirLabel =
activeDirection.value === '0'
? t('page.weightRatio.tabClockwise')
: t('page.weightRatio.tabCounterclockwise')
return `${dirLabel} ${t('page.weightShared.weightColSuffix')}`
})
const tierKeys = TIER_KEYS
@@ -470,7 +476,7 @@
grouped.value = parsePayload(res)
})
.catch(() => {
ElMessage.error('获取权重数据失败')
ElMessage.error(t('page.weightShared.fetchFail'))
})
.finally(() => {
loading.value = false
@@ -499,19 +505,19 @@
function handleSubmit() {
const items = collectItems()
if (items.length === 0) {
ElMessage.info('没有可提交的配置')
ElMessage.info(t('page.weightShared.nothingToSubmit'))
return
}
submitting.value = true
api
.batchUpdateWeights(items)
.then(() => {
ElMessage.success('保存成功')
ElMessage.success(t('page.weightShared.saveSuccess'))
emit('success')
handleClose()
})
.catch((e: { message?: string }) => {
ElMessage.error(e?.message ?? '保存失败')
ElMessage.error(e?.message ?? t('page.weightShared.submitFail'))
})
.finally(() => {
submitting.value = false