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 App from './App.vue';
|
||||||
import { router } from './router';
|
import { router } from './router';
|
||||||
// 自动导入语言文件
|
// 自动导入语言文件
|
||||||
|
interface LocaleMessages {
|
||||||
|
[key: string]: string;
|
||||||
|
}
|
||||||
|
|
||||||
const messages = Object.fromEntries(
|
const messages = Object.fromEntries(
|
||||||
Object.entries(import.meta.glob('./locales/*.json', { eager: true })).map(([key, value]) => {
|
Object.entries(import.meta.glob<Record<string, LocaleMessages>>('./locales/*.json', { eager: true })).map(
|
||||||
return [key.slice('./locales/'.length, -5), value.default];
|
([key, value]) => {
|
||||||
}),
|
return [key.slice('./locales/'.length, -5), value.default];
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
|
Reference in New Issue
Block a user