feat(admin): 从已有玩家升级代理、修复 i18n 与过期 .js 冲突

- 新建一级代理改为选择已有玩家;新建用户可选一级代理

- 操作日志/注单等扁平 key 翻译;清理 src 内误生成 .js,Vite 优先解析 .ts

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-03 15:42:15 +08:00
parent cbfa18d1d3
commit 3b739982a1
27 changed files with 625 additions and 165 deletions

View File

@@ -0,0 +1,19 @@
import { resolveAdminMessage } from '../i18n/resolve-message';
import type { AdminLocale } from '../i18n/admin-messages';
import { getAdminLocale } from '../i18n';
export function auditActionLabel(action: string, locale?: AdminLocale) {
return resolveAdminMessage(`audit.action.${action}`, locale) ?? action;
}
export function auditModuleLabel(module: string, locale?: AdminLocale) {
return resolveAdminMessage(`audit.module.${module}`, locale) ?? module;
}
export function useAuditLabels() {
const loc = () => getAdminLocale();
return {
auditActionLabel: (action: string) => auditActionLabel(action, loc()),
auditModuleLabel: (module: string) => auditModuleLabel(module, loc()),
};
}

View File

@@ -1,6 +1,8 @@
import { computed } from 'vue';
import { adminT, type AdminLocale } from '../i18n/admin-messages';
import { getAdminLocale, useAdminLocale } from '../composables/useAdminLocale';
import { resolveAdminMessage } from '../i18n/resolve-message';
import type { AdminLocale } from '../i18n/admin-messages';
import { getAdminLocale } from '../i18n';
import { useAdminLocale } from '../composables/useAdminLocale';
export type BetTagType = '' | 'info' | 'success' | 'warning' | 'danger';
@@ -12,13 +14,13 @@ const STATUS_TAG: Record<string, BetTagType> = {
REFUNDED: 'info',
};
function loc(): AdminLocale {
return getAdminLocale();
function translateKey(key: string, locale?: AdminLocale): string {
return resolveAdminMessage(key, locale) ?? key;
}
export function betStatusLabel(status: string) {
export function betStatusLabel(status: string, locale?: AdminLocale) {
const key = `bet.status.${status}`;
const v = adminT(loc(), key);
const v = translateKey(key, locale);
return v !== key ? v : status;
}
@@ -26,23 +28,23 @@ export function betStatusTagType(status: string): BetTagType {
return STATUS_TAG[status] ?? 'info';
}
export function betTypeLabel(betType: string) {
export function betTypeLabel(betType: string, locale?: AdminLocale) {
const key = `bet.type.${betType}`;
const v = adminT(loc(), key);
const v = translateKey(key, locale);
return v !== key ? v : betType;
}
export function betSettlementLabel(v: string | null | undefined) {
export function betSettlementLabel(v: string | null | undefined, locale?: AdminLocale) {
if (!v) return '—';
const key = `bet.settlement.${v}`;
const label = adminT(loc(), key);
const label = translateKey(key, locale);
return label !== key ? label : v;
}
export function betResultLabel(s: string | null | undefined) {
export function betResultLabel(s: string | null | undefined, locale?: AdminLocale) {
if (!s) return '—';
const key = `bet.result.${s}`;
const label = adminT(loc(), key);
const label = translateKey(key, locale);
return label !== key ? label : s;
}

View File

@@ -1,4 +1,4 @@
import { getAdminLocale } from '../composables/useAdminLocale';
import { getAdminLocale } from '../i18n';
import type { AdminLocale } from '../i18n/admin-messages';
function resolveLocale(locale?: AdminLocale): AdminLocale {