This commit is contained in:
wchino
2026-06-13 17:38:25 +08:00
parent e7e938f261
commit 7b33d9f9fa
190 changed files with 23222 additions and 4336 deletions

View File

@@ -1,45 +1,7 @@
/** 详情页展示顺序(与产品设计稿一致) */
export const FEATURED_MARKET_TYPES = [
'FT_CORRECT_SCORE',
'HT_CORRECT_SCORE',
'SH_CORRECT_SCORE',
] as const;
/** 详情页统一列表顺序:波胆在前,其余玩法在后 */
export const DETAIL_MARKET_TYPES = [
...FEATURED_MARKET_TYPES,
'FT_HANDICAP',
'FT_OVER_UNDER',
'FT_1X2',
'FT_ODD_EVEN',
'HT_HANDICAP',
'HT_OVER_UNDER',
'HT_1X2',
] as const;
export const GRID_MARKET_TYPES = [
'FT_HANDICAP',
'FT_OVER_UNDER',
'FT_1X2',
'FT_ODD_EVEN',
'HT_HANDICAP',
'HT_OVER_UNDER',
'HT_1X2',
] as const;
export type CatalogMarketType =
| (typeof FEATURED_MARKET_TYPES)[number]
| (typeof GRID_MARKET_TYPES)[number];
export const MARKET_I18N_KEY: Record<string, string> = {
FT_CORRECT_SCORE: 'bet.market_cs',
HT_CORRECT_SCORE: 'bet.market_ht_cs',
SH_CORRECT_SCORE: 'bet.market_sh_cs',
FT_HANDICAP: 'bet.market_ft_handicap',
FT_OVER_UNDER: 'bet.market_ft_ou',
FT_1X2: 'bet.market_ft_1x2',
FT_ODD_EVEN: 'bet.market_ft_oe',
HT_HANDICAP: 'bet.market_ht_handicap',
HT_OVER_UNDER: 'bet.market_ht_ou',
HT_1X2: 'bet.market_ht_1x2',
};
export {
DETAIL_MARKET_TYPES,
FEATURED_MARKET_TYPES,
GRID_MARKET_TYPES,
MARKET_I18N_KEY,
type FootballMarketType as CatalogMarketType,
} from '@thebet365/shared';

View File

@@ -0,0 +1,5 @@
export {
isAfterLocalToday as isAfterTodayMatchWindow,
isInLocalToday as isInTodayMatchWindow,
isSameLocalCalendarDay as isSameCalendarDay,
} from '@thebet365/shared';

View File

@@ -1,44 +0,0 @@
/** 串关列表表头与玩法类型labelKey 对应 main.ts bet.* */
export const PARLAY_MARKET_TYPES = [
{ key: 'FT_HANDICAP', labelKey: 'market_ft_handicap' },
{ key: 'FT_OVER_UNDER', labelKey: 'market_ft_ou' },
{ key: 'FT_1X2', labelKey: 'market_ft_1x2' },
{ key: 'FT_ODD_EVEN', labelKey: 'market_ft_oe' },
{ key: 'HT_HANDICAP', labelKey: 'market_ht_handicap' },
{ key: 'HT_OVER_UNDER', labelKey: 'market_ht_ou' },
{ key: 'HT_1X2', labelKey: 'market_ht_1x2' },
] as const;
export type ParlayMarketType = (typeof PARLAY_MARKET_TYPES)[number]['key'];
/** 按全场 / 半场分组headerKey 对应 bet.ft / bet.ht */
export const PARLAY_MARKET_GROUPS = [
{
headerKey: 'ft',
columns: [
{ key: 'FT_HANDICAP', labelKey: 'parlay_lbl_handicap' },
{ key: 'FT_OVER_UNDER', labelKey: 'parlay_lbl_ou' },
{ key: 'FT_1X2', labelKey: 'parlay_lbl_1x2' },
{ key: 'FT_ODD_EVEN', labelKey: 'parlay_lbl_oe' },
],
},
{
headerKey: 'ht',
columns: [
{ key: 'HT_HANDICAP', labelKey: 'parlay_lbl_handicap' },
{ key: 'HT_OVER_UNDER', labelKey: 'parlay_lbl_ou' },
{ key: 'HT_1X2', labelKey: 'parlay_lbl_1x2' },
],
},
] as const;
/** 选项简称 i18n key串关格内展示 */
export const PARLAY_SELECTION_KEYS: Record<string, string> = {
HOME: 'parlay_sel_home',
AWAY: 'parlay_sel_away',
DRAW: 'parlay_sel_draw',
OVER: 'parlay_sel_over',
UNDER: 'parlay_sel_under',
ODD: 'parlay_sel_odd',
EVEN: 'parlay_sel_even',
};

View File

@@ -15,14 +15,41 @@ export function resolveSelectionLabel(
t: (key: string) => string,
code: string,
fallback: string,
opts?: { lineValue?: string | number | null },
): string {
const i18nKey = CODE_I18N[code];
if (i18nKey) {
const fullKey = `bet.${i18nKey}`;
const v = t(fullKey);
if (v !== fullKey) return v;
if (v !== fullKey) return withLineValue(code, v, opts?.lineValue);
}
const parsed = parseScoreCode(code, t);
if (parsed) return parsed.display;
return fallback;
}
function parseLineValue(value: string | number | null | undefined) {
if (value == null || value === '') return null;
const n = typeof value === 'number' ? value : Number(value);
return Number.isFinite(n) ? n : null;
}
function formatLineValue(value: number) {
const n = Object.is(value, -0) ? 0 : value;
if (Number.isInteger(n)) return String(n);
return String(n).replace(/(\.\d*?)0+$/, '$1').replace(/\.$/, '');
}
function formatSignedLineValue(value: number) {
const n = Object.is(value, -0) ? 0 : value;
return n > 0 ? `+${formatLineValue(n)}` : formatLineValue(n);
}
function withLineValue(code: string, label: string, value: string | number | null | undefined) {
const line = parseLineValue(value);
if (line == null) return label;
if (code === 'HOME') return `${label} ${formatSignedLineValue(line)}`;
if (code === 'AWAY') return `${label} ${formatSignedLineValue(-line)}`;
if (code === 'OVER' || code === 'UNDER') return `${label} ${formatLineValue(line)}`;
return label;
}