From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目
---
src/plugins/vueI18n/index.ts | 42 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/src/plugins/vueI18n/index.ts b/src/plugins/vueI18n/index.ts
new file mode 100644
index 0000000..f845b13
--- /dev/null
+++ b/src/plugins/vueI18n/index.ts
@@ -0,0 +1,42 @@
+import type { App } from 'vue'
+import { createI18n } from 'vue-i18n'
+import { useLocaleStoreWithOut } from '@/store/modules/locale'
+import type { I18n, I18nOptions } from 'vue-i18n'
+import { setHtmlPageLang } from './helper'
+
+export let i18n: ReturnType<typeof createI18n>
+
+const createI18nOptions = async (): Promise<I18nOptions> => {
+ const localeStore = useLocaleStoreWithOut()
+ const locale = localeStore.getCurrentLocale
+ const localeMap = localeStore.getLocaleMap
+ const defaultLocal = await import(`../../locales/${locale.lang}.ts`)
+ const message = defaultLocal.default ?? {}
+
+ setHtmlPageLang(locale.lang)
+
+ localeStore.setCurrentLocale({
+ lang: locale.lang
+ // elLocale: elLocal
+ })
+
+ return {
+ legacy: false,
+ locale: locale.lang,
+ fallbackLocale: locale.lang,
+ messages: {
+ [locale.lang]: message
+ },
+ availableLocales: localeMap.map((v) => v.lang),
+ sync: true,
+ silentTranslationWarn: true,
+ missingWarn: false,
+ silentFallbackWarn: true
+ }
+}
+
+export const setupI18n = async (app: App<Element>) => {
+ const options = await createI18nOptions()
+ i18n = createI18n(options) as I18n
+ app.use(i18n)
+}
--
Gitblit v1.8.0