feat: WC2026 赛事 seed、生产上线初始化脚本与目录归档
重构 seed 为 WC2026 72 场小组赛与 48 强优胜盘;新增 production 模式仅保留 admin 与赛事示例;提供 prod-init-db 全量重置脚本;管理端 i18n 分包与赛事归档能力。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
32
apps/admin/src/i18n/locale-loader.ts
Normal file
32
apps/admin/src/i18n/locale-loader.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import type { AdminLocale } from './admin-messages';
|
||||
import { adminMessages } from './admin-messages';
|
||||
|
||||
const loaders: Record<AdminLocale, () => Promise<{ default: Record<string, string> }>> = {
|
||||
'zh-CN': () => import('./bundles/zh-CN'),
|
||||
'en-US': () => import('./bundles/en-US'),
|
||||
'ms-MY': () => import('./bundles/ms-MY'),
|
||||
};
|
||||
|
||||
const inflight = new Map<AdminLocale, Promise<void>>();
|
||||
|
||||
/** 按语言动态加载文案包(仅当前 locale 进入主路径,其余为独立 chunk)。 */
|
||||
export async function ensureAdminLocaleLoaded(locale: AdminLocale): Promise<void> {
|
||||
if (Object.keys(adminMessages[locale]).length > 0) return;
|
||||
const pending = inflight.get(locale);
|
||||
if (pending) return pending;
|
||||
|
||||
const task = loaders[locale]().then((mod) => {
|
||||
adminMessages[locale] = mod.default;
|
||||
});
|
||||
inflight.set(locale, task);
|
||||
try {
|
||||
await task;
|
||||
} finally {
|
||||
inflight.delete(locale);
|
||||
}
|
||||
}
|
||||
|
||||
/** 切换语言时预加载目标 locale(与 ensureAdminLocaleLoaded 相同,供 setLocale 调用)。 */
|
||||
export async function preloadAdminLocale(locale: AdminLocale): Promise<void> {
|
||||
await ensureAdminLocaleLoaded(locale);
|
||||
}
|
||||
Reference in New Issue
Block a user