diff --git a/package.json b/package.json
index 2faed4e..9019548 100644
--- a/package.json
+++ b/package.json
@@ -9,6 +9,7 @@
"build-jar-auto": "run-p \"build-only\" && gradle -Dorg.gradle.java.home=/opt/jdk/21.0.7/ build-jar",
"build": "run-p type-check \"build-only {@}\" --",
"preview": "vite preview",
+ "build-preview": "run-p build-only && vite preview",
"build-only": "vite build",
"type-check": "vue-tsc --build",
"lint:oxlint": "oxlint . --fix -D correctness --ignore-path .gitignore",
diff --git a/web-src/layout/Head.vue b/web-src/layout/Head.vue
index 726b146..24aba37 100644
--- a/web-src/layout/Head.vue
+++ b/web-src/layout/Head.vue
@@ -16,7 +16,7 @@
}"
@click="router.push({ name: 'home' })">
- {{ t('nav.title.home') }}
+ {{ $t('nav.title.home') }}
import Icon from '@/components/Icon.vue';
import { UseBoolRef } from '@/util';
-import {
- type languageIndexItemValueType,
- message,
- messageData,
- router,
- t,
- UseAuthStore,
- UseSettingStore,
-} from '@/plugin';
+import { type languageIndexItemValueType, message, messageData, router, UseAuthStore, UseSettingStore } from '@/plugin';
import { getSysInfo } from '@/api/system.ts';
import type { SelectOption } from 'naive-ui/es/select/src/interface';
import type { VNodeChild } from 'vue';
diff --git a/web-src/main.ts b/web-src/main.ts
index cf8b19b..d41823f 100644
--- a/web-src/main.ts
+++ b/web-src/main.ts
@@ -4,13 +4,13 @@ import './assets/index.sass';
import { createApp } from 'vue';
import App from './App.vue';
-import { installI18n, pinia, router } from './plugin';
+import { i18n, installI18n, pinia, router } from './plugin';
-installI18n().then((i18n) => {
- const app = createApp(App);
- app.use(i18n);
- app.use(pinia);
- app.use(router);
- app.mount('#app');
- console.log(i18n);
-});
+const app = createApp(App);
+app.use(i18n);
+app.use(pinia);
+app.use(router);
+app.mount('#app');
+console.log(i18n);
+
+await installI18n();
diff --git a/web-src/plugin/i18n/index.ts b/web-src/plugin/i18n/index.ts
index c70d2ff..19cfdff 100644
--- a/web-src/plugin/i18n/index.ts
+++ b/web-src/plugin/i18n/index.ts
@@ -32,22 +32,12 @@ export const messages: languageType | any = {};
export const messageData = ref([]);
-export let i18n: ReturnType<
- typeof createI18n<
- {
- legacy: boolean;
- locale: string;
- fallbackLocale: string;
- messages: any;
- },
- any,
- any
- >
->;
-
-export function t(data: string): string {
- return i18n.global.t(data);
-}
+export const i18n = createI18n({
+ legacy: false,
+ locale: 'zh-cn',
+ fallbackLocale: 'zh-cn',
+ messages,
+});
export async function installI18n() {
const data: languageIndexType = await loadIndexFile();
@@ -59,14 +49,4 @@ export async function installI18n() {
});
messages[i.id] = await loadLanguageFile(i.file);
}
- console.log(messages);
- console.log(languagedatas);
- console.log(messageData);
- i18n = createI18n({
- legacy: false,
- locale: 'zh-cn',
- fallbackLocale: 'zh-cn',
- messages,
- });
- return i18n;
}