fix: When refreshing the page, the topic is wrong

This commit is contained in:
vben
2024-05-25 22:43:22 +08:00
parent 352119cc3a
commit f2644dbbc5
11 changed files with 38 additions and 24 deletions

View File

@@ -1,2 +1,4 @@
# spa-title
VITE_GLOB_APP_TITLE = Vben Admin Pro
VITE_APP_NAMESPACE = antd-view

View File

@@ -8,14 +8,14 @@ import { createApp } from 'vue';
import App from './app.vue';
import { router } from './router';
async function bootstrap(namespace: string, env: string) {
async function bootstrap(namespace: string) {
const app = createApp(App);
// 国际化 i18n 配置
await setupI18n(app, { defaultLocale: preference.locale });
// 配置 pinia-store
await setupStore(app, { env, namespace });
await setupStore(app, { namespace });
// 配置路由及路由守卫
app.use(router);

View File

@@ -6,17 +6,16 @@ import { overridesPreference } from './preference';
* 应用初始化完成之后再进行页面加载渲染
*/
async function initApplication() {
const namespace = 'antd-view';
const env = import.meta.env.PROD ? 'prod' : 'dev';
const namespace = `${import.meta.env.VITE_APP_NAMESPACE}-${env}`;
// app偏好设置初始化
await setupPreference({
env,
namespace,
overrides: overridesPreference,
});
import('./bootstrap').then((m) => m.bootstrap(namespace, env));
import('./bootstrap').then((m) => m.bootstrap(namespace));
}
initApplication();