feat(i18n): 更新语言文件导入逻辑,增强类型支持
This commit is contained in:
12
src/main.ts
12
src/main.ts
@ -10,10 +10,16 @@ import { DataLoaderPlugin } from 'unplugin-vue-router/data-loaders';
|
||||
import App from './App.vue';
|
||||
import { router } from './router';
|
||||
// 自动导入语言文件
|
||||
interface LocaleMessages {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
const messages = Object.fromEntries(
|
||||
Object.entries(import.meta.glob('./locales/*.json', { eager: true })).map(([key, value]) => {
|
||||
return [key.slice('./locales/'.length, -5), value.default];
|
||||
}),
|
||||
Object.entries(import.meta.glob<Record<string, LocaleMessages>>('./locales/*.json', { eager: true })).map(
|
||||
([key, value]) => {
|
||||
return [key.slice('./locales/'.length, -5), value.default];
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
async function init() {
|
||||
|
Reference in New Issue
Block a user