+
+
+
+
+
{{ $tm('AlertInfo.capture.title') }}
+
-
diff --git a/src/entry-client.ts b/src/entry-client.ts
index e233f270..5a30300f 100644
--- a/src/entry-client.ts
+++ b/src/entry-client.ts
@@ -1,7 +1,7 @@
import { createApp } from './main'
import { createKUNGalgameRouter } from './router'
import { setupPinia } from './store'
-import i18n from '@/language/i18n'
+import createI18n from '@/language/i18n'
import '@/styles/index.scss'
const router = createKUNGalgameRouter()
@@ -9,6 +9,8 @@ const pinia = setupPinia()
const { app } = createApp()
+export const i18n = createI18n()
+
app.use(router).use(pinia).use(i18n)
if (window.__pinia) {
diff --git a/src/entry-server.ts b/src/entry-server.ts
index 8ee4c7bb..a6fccf9d 100644
--- a/src/entry-server.ts
+++ b/src/entry-server.ts
@@ -2,7 +2,7 @@ import { createApp } from './main'
import { createKUNGalgameRouter } from './router'
import { setupPinia } from './store'
-import i18n from '@/language/i18n'
+import createI18n from '@/language/i18n'
import { renderToString } from '@vue/server-renderer'
@@ -46,9 +46,11 @@ const renderPreloadLinks = (
export const render = async (
ctx: ParameterizedContext,
- manifest: Record
-): Promise<[string, string, string]> => {
+ manifest: Record,
+ options: { language: string; country: string }
+) => {
const { app } = createApp()
+ const { language, country } = options
// router
const router = createKUNGalgameRouter()
@@ -63,7 +65,9 @@ export const render = async (
const renderedPinia = JSON.stringify(pinia.state.value)
// i18n
- app.use(i18n)
+ app.use(createI18n(
+ language.includes('zh') ? 'zh' : 'en',
+ ))
const renderCtx: { modules?: string[] } = {}
@@ -71,5 +75,9 @@ export const render = async (
const renderedLinks = renderPreloadLinks(renderCtx.modules, manifest)
- return [renderedHtml, renderedPinia, renderedLinks]
+ const renderedTeleports = renderCtx.teleports as {
+ '#teleported': string
+ }
+
+ return [renderedHtml, renderedPinia, renderedLinks, renderedTeleports]
}
diff --git a/src/language/i18n.ts b/src/language/i18n.ts
index ba525f40..b81da379 100644
--- a/src/language/i18n.ts
+++ b/src/language/i18n.ts
@@ -1,4 +1,4 @@
-import { createI18n } from 'vue-i18n'
+import { createI18n as _createI18n } from 'vue-i18n'
// 读取本地存储中的语言配置
import { KUNGalgameLanguage } from '@/utils/getDefaultEnv'
@@ -6,8 +6,8 @@ import { KUNGalgameLanguage } from '@/utils/getDefaultEnv'
import zh from './zh'
import en from './en'
-const i18n = createI18n({
- locale: KUNGalgameLanguage,
+const createI18n = (language?: string) => _createI18n({
+ locale: language || KUNGalgameLanguage,
legacy: false,
messages: {
zh,
@@ -15,4 +15,4 @@ const i18n = createI18n({
},
})
-export default i18n
+export default createI18n
diff --git a/src/router/guard/index.ts b/src/router/guard/index.ts
index bf5b3e3b..8106d00c 100644
--- a/src/router/guard/index.ts
+++ b/src/router/guard/index.ts
@@ -1,6 +1,6 @@
import { Router } from 'vue-router'
import { createPermission } from './permission'
-import i18n from '@/language/i18n'
+import { i18n } from '@/entry-client'
const createPageTitle = (router: Router) => {
router.beforeEach((to) => {
diff --git a/vite.config.ts b/vite.config.ts
index dcb289da..e3e9b560 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -5,26 +5,28 @@ import vue from '@vitejs/plugin-vue'
import { visualizer } from 'rollup-plugin-visualizer'
// https://vitejs.dev/config/
-export default defineConfig({
- plugins: [vue(), visualizer() as PluginOption],
- /* Set the 'src' alias to '@' */
- resolve: {
- alias: {
- '@': path.resolve(__dirname, './src'),
+export default defineConfig(({ mode, ssrBuild, command }) => {
+ return {
+ plugins: [vue(), visualizer() as PluginOption],
+ /* Set the 'src' alias to '@' */
+ resolve: {
+ alias: {
+ '@': path.resolve(__dirname, './src'),
+ },
},
- },
- esbuild: {
- drop: ['console', 'debugger'],
- },
- build: {
- // Dist dir name
- assetsDir: 'kun',
- },
- server: { host: '127.0.0.1', port: 1007 },
- // Suppress i18n warnings
- define: {
- __VUE_I18N_FULL_INSTALL__: true,
- __VUE_I18N_LEGACY_API__: false,
- __INTLIFY_PROD_DEVTOOLS__: false,
- },
+ esbuild: command === 'serve' ? {} : {
+ drop: ['console', 'debugger']
+ },
+ build: {
+ // Dist dir name
+ assetsDir: 'kun',
+ },
+ server: { host: '127.0.0.1', port: 1007 },
+ // Suppress i18n warnings
+ define: {
+ __VUE_I18N_FULL_INSTALL__: true,
+ __VUE_I18N_LEGACY_API__: false,
+ __INTLIFY_PROD_DEVTOOLS__: false,
+ },
+ }
})