feat(i18n): 移除国际化
This commit is contained in:
23
src/main.ts
23
src/main.ts
@ -4,23 +4,10 @@ import 'virtual:uno.css';
|
||||
|
||||
import { createHead } from '@unhead/vue';
|
||||
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
|
||||
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<Record<string, LocaleMessages>>('./locales/*.json', { eager: true })).map(
|
||||
([key, value]) => {
|
||||
return [key.slice('./locales/'.length, -5), value.default];
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
async function init() {
|
||||
if (import.meta.env.MODE === 'development' || 1 === 1) {
|
||||
@ -42,15 +29,7 @@ async function init() {
|
||||
// Register the plugin before the router
|
||||
.use(DataLoaderPlugin, { router })
|
||||
// adding the router will trigger the initial navigation
|
||||
.use(router)
|
||||
.use(
|
||||
createI18n({
|
||||
legacy: false, // 使用 Composition API 模式
|
||||
locale: 'zh', // 默认语言
|
||||
fallbackLocale: 'en', // 回退语言
|
||||
messages,
|
||||
}),
|
||||
);
|
||||
.use(router);
|
||||
app.config.globalProperties.$__DEV__ = $__DEV__;
|
||||
app.mount('#app');
|
||||
}
|
||||
|
Reference in New Issue
Block a user