feat(admin): 从已有玩家升级代理、修复 i18n 与过期 .js 冲突
- 新建一级代理改为选择已有玩家;新建用户可选一级代理 - 操作日志/注单等扁平 key 翻译;清理 src 内误生成 .js,Vite 优先解析 .ts Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
19
apps/admin/src/utils/audit-labels.ts
Normal file
19
apps/admin/src/utils/audit-labels.ts
Normal 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()),
|
||||
};
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user