调整前端两套互不连通的 HTTP 请求层并存、两套布局框架并存、两套 Pinia 实例并存问题
This commit is contained in:
11
src/locales/index.ts
Normal file
11
src/locales/index.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
const localeModules = import.meta.glob<{ default: Record<string, unknown> }>('./*.ts')
|
||||
|
||||
export async function loadLocaleMessages(locale: string) {
|
||||
const path = `./${locale}.ts`
|
||||
const loader = localeModules[path]
|
||||
if (!loader) {
|
||||
throw new Error(`Locale not found: ${locale}`)
|
||||
}
|
||||
const mod = await loader()
|
||||
return mod.default ?? {}
|
||||
}
|
||||
Reference in New Issue
Block a user