feat(i18n): 管理端与玩家端三语支持(中/英/马来语)

- 管理后台 adminT 文案库、结算与代理端页面、表单校验
- 玩家端 vue-i18n 补全首页/公告/串关与 ms 文案
- Element Plus ms 语言包与共享 locale 工具
This commit is contained in:
2026-06-03 15:05:36 +08:00
parent 80adc0e928
commit cbfa18d1d3
63 changed files with 3081 additions and 1038 deletions

View File

@@ -3,7 +3,9 @@ import { ref, computed, onMounted } from 'vue';
import { useI18n } from 'vue-i18n';
import api from '../../api';
import { useBetSlipStore } from '../../stores/betSlip';
import { PARLAY_MARKET_TYPES, SELECTION_SHORT } from '../../utils/parlayColumns';
import { PARLAY_MAX_LEGS, canSelectForParlay } from '@thebet365/shared';
import { PARLAY_MARKET_TYPES, PARLAY_SELECTION_KEYS } from '../../utils/parlayColumns';
import BetGuideHelp from '../BetGuideHelp.vue';
type TimeFilter = 'all' | 'today';
@@ -18,6 +20,8 @@ interface Selection {
interface Market {
id: string;
marketType: string;
lineValue?: string | number | null;
allowParlay?: boolean;
selections: Selection[];
}
@@ -51,10 +55,25 @@ onMounted(async () => {
}
});
function parseLine(v: string | number | null | undefined) {
if (v == null || v === '') return null;
const n = typeof v === 'number' ? v : parseFloat(String(v));
return Number.isFinite(n) ? n : null;
}
function isParlayEligibleMarket(market: Market) {
if (!market.selections.length) return false;
return canSelectForParlay({
marketType: market.marketType,
lineValue: parseLine(market.lineValue),
allowParlay: market.allowParlay ?? true,
}).ok;
}
function hasParlayMarkets(m: ParlayMatch) {
return parlayMarketKeys.some((key) => {
const market = m.markets?.find((mk) => mk.marketType === key);
return market && market.selections.length > 0;
return market && isParlayEligibleMarket(market);
});
}
@@ -98,15 +117,23 @@ function formatOdds(odds: string) {
}
function selLabel(sel: Selection) {
return SELECTION_SHORT[sel.selectionCode] ?? sel.selectionName.slice(0, 2);
const key = PARLAY_SELECTION_KEYS[sel.selectionCode];
if (key) return t(`bet.${key}`);
return sel.selectionName.slice(0, 2);
}
function colLabel(labelKey: string) {
return t(`bet.${labelKey}`);
}
function isPicked(selectionId: string) {
return slip.items.some((i) => i.selectionId === selectionId);
}
const parlayHint = ref('');
function pickSelection(match: ParlayMatch, market: Market, sel: Selection) {
slip.addParlayLeg({
const err = slip.addParlayLeg({
selectionId: sel.id,
oddsVersion: String(sel.oddsVersion),
matchId: match.id,
@@ -114,7 +141,14 @@ function pickSelection(match: ParlayMatch, market: Market, sel: Selection) {
selectionName: `${selLabel(sel)} ${formatOdds(sel.odds)}`,
odds: parseFloat(sel.odds),
marketType: market.marketType,
lineValue: parseLine(market.lineValue),
allowParlay: market.allowParlay,
});
if (err === 'MAX_LEGS') parlayHint.value = t('bet.parlay_max_legs');
else if (err === 'QUARTER_LINE') parlayHint.value = t('bet.parlay_block_quarter');
else if (err === 'OUTRIGHT') parlayHint.value = t('bet.parlay_block_outright');
else if (err === 'NOT_ALLOWED') parlayHint.value = t('bet.parlay_block_not_allowed');
else parlayHint.value = '';
}
function openSlip() {
@@ -126,21 +160,28 @@ const showParlayFoot = computed(() => slip.mode === 'parlay' && slip.count > 0);
<template>
<div class="parlay-panel" :class="{ 'has-fixed-foot': showParlayFoot }">
<header class="panel-head">
<div class="head-title">
<span class="layers-icon" aria-hidden="true" />
<h2>{{ t('bet.parlay_title') }}</h2>
</div>
<p class="head-desc">{{ t('bet.parlay_desc') }}</p>
</header>
<div class="toolbar">
<select v-model="timeFilter" class="filter-select">
<div class="toolbar-filters">
<select v-model="timeFilter" class="filter-select">
<option value="all">{{ t('bet.parlay_filter_all') }}</option>
<option value="today">{{ t('bet.tab_today') }}</option>
</select>
</select>
<BetGuideHelp
:title="t('bet.parlay_guide_title')"
:aria-label="t('bet.parlay_guide_help')"
storage-key="thebet365_parlay_guide_seen"
>
<p class="intro">{{ t('bet.parlay_desc') }}</p>
<ol>
<li>{{ t('bet.parlay_guide_1') }}</li>
<li>{{ t('bet.parlay_guide_2') }}</li>
<li>{{ t('bet.parlay_guide_3') }}</li>
</ol>
<p class="rules-link">{{ t('bet.guide_rules_link') }}</p>
</BetGuideHelp>
</div>
<div class="col-headers">
<span v-for="col in PARLAY_MARKET_TYPES" :key="col.key" class="col-head">{{ col.label }}</span>
<span v-for="col in PARLAY_MARKET_TYPES" :key="col.key" class="col-head">{{ colLabel(col.labelKey) }}</span>
</div>
</div>
@@ -159,7 +200,12 @@ const showParlayFoot = computed(() => slip.mode === 'parlay' && slip.count > 0);
:key="col.key"
class="market-cell"
>
<template v-if="getMarket(match, col.key)?.selections.length">
<template
v-if="
getMarket(match, col.key) &&
isParlayEligibleMarket(getMarket(match, col.key)!)
"
>
<button
v-for="sel in getMarket(match, col.key)!.selections"
:key="sel.id"
@@ -185,7 +231,9 @@ const showParlayFoot = computed(() => slip.mode === 'parlay' && slip.count > 0);
<Teleport to="body">
<div v-if="showParlayFoot" class="parlay-foot-fixed">
<p v-if="slip.count < 2" class="foot-hint">{{ t('bet.parlay_need_more') }}</p>
<p v-if="parlayHint" class="foot-hint foot-hint--warn">{{ parlayHint }}</p>
<p v-else-if="slip.count < 2" class="foot-hint">{{ t('bet.parlay_need_more') }}</p>
<p v-else-if="slip.count > PARLAY_MAX_LEGS" class="foot-hint">{{ t('bet.parlay_max_legs') }}</p>
<p v-else class="foot-meta">
{{ t('bet.bet_slip') }} ({{ slip.count }}) · {{ t('bet.parlay') }}
{{ slip.totalOdds.toFixed(2) }}
@@ -193,7 +241,7 @@ const showParlayFoot = computed(() => slip.mode === 'parlay' && slip.count > 0);
<button
type="button"
class="market-foot-btn"
:disabled="slip.count < 2"
:disabled="!slip.canPlaceParlay"
@click="openSlip"
>
{{ t('bet.cs_confirm_cell') }}
@@ -212,43 +260,11 @@ const showParlayFoot = computed(() => slip.mode === 'parlay' && slip.count > 0);
padding-bottom: 100px;
}
.panel-head {
background: #141414;
border: 1px solid #2a2a2a;
border-radius: 8px;
padding: 14px 12px;
margin-bottom: 12px;
}
.head-title {
.toolbar-filters {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 8px;
}
.layers-icon {
width: 26px;
height: 20px;
gap: 8px;
flex-shrink: 0;
background:
linear-gradient(#2e9e5e, #2e9e5e) 0 0 / 100% 4px no-repeat,
linear-gradient(#2e9e5e, #2e9e5e) 0 8px / 85% 4px no-repeat,
linear-gradient(#2e9e5e, #2e9e5e) 0 16px / 70% 4px no-repeat;
border-radius: 2px;
}
.head-title h2 {
font-size: 18px;
font-weight: 800;
color: var(--text);
}
.head-desc {
font-size: 12px;
color: var(--text-muted);
line-height: 1.45;
margin-bottom: 10px;
}
.parlay-foot-fixed {
@@ -267,6 +283,10 @@ const showParlayFoot = computed(() => slip.mode === 'parlay' && slip.count > 0);
.foot-meta {
margin: 0 0 8px;
font-size: 11px;
}
.foot-hint--warn {
color: var(--danger);
color: var(--text-muted);
text-align: center;
}
@@ -322,11 +342,12 @@ const showParlayFoot = computed(() => slip.mode === 'parlay' && slip.count > 0);
}
.col-head {
font-size: 9px;
font-size: 10px;
font-weight: 800;
color: var(--text-muted);
text-align: center;
letter-spacing: 0.02em;
line-height: 1.25;
word-break: keep-all;
}
.table-wrap {