2024-11-05 13:58:56 +08:00
|
|
|
import { createApp, watchEffect } from 'vue';
|
2024-05-24 23:11:03 +08:00
|
|
|
|
2024-07-30 21:10:28 +08:00
|
|
|
import { registerAccessDirective } from '@vben/access';
|
2024-11-05 13:58:56 +08:00
|
|
|
import { preferences } from '@vben/preferences';
|
2024-07-30 21:10:28 +08:00
|
|
|
import { initStores } from '@vben/stores';
|
2024-06-08 19:49:06 +08:00
|
|
|
import '@vben/styles';
|
2024-07-08 22:30:19 +08:00
|
|
|
import '@vben/styles/antd';
|
2024-06-01 23:15:29 +08:00
|
|
|
|
2024-11-05 13:58:56 +08:00
|
|
|
import { useTitle } from '@vueuse/core';
|
|
|
|
|
2024-09-19 08:39:47 +08:00
|
|
|
import { setupGlobalComponent } from '#/components/global';
|
2024-11-05 13:58:56 +08:00
|
|
|
import { $t, setupI18n } from '#/locales';
|
2024-05-24 23:11:03 +08:00
|
|
|
|
2024-10-13 18:33:43 +08:00
|
|
|
import { initComponentAdapter } from './adapter/component';
|
2024-05-24 23:11:03 +08:00
|
|
|
import App from './app.vue';
|
|
|
|
import { router } from './router';
|
|
|
|
|
2024-05-25 22:43:22 +08:00
|
|
|
async function bootstrap(namespace: string) {
|
2024-10-13 18:33:43 +08:00
|
|
|
// 初始化组件适配器
|
|
|
|
await initComponentAdapter();
|
|
|
|
|
2024-05-24 23:11:03 +08:00
|
|
|
const app = createApp(App);
|
|
|
|
|
2024-09-19 08:39:47 +08:00
|
|
|
// 全局组件
|
|
|
|
setupGlobalComponent(app);
|
|
|
|
|
2024-05-24 23:11:03 +08:00
|
|
|
// 国际化 i18n 配置
|
2024-07-28 14:29:05 +08:00
|
|
|
await setupI18n(app);
|
2024-05-24 23:11:03 +08:00
|
|
|
|
2024-07-30 21:05:03 +08:00
|
|
|
// 配置 pinia-tore
|
2024-07-30 21:10:28 +08:00
|
|
|
await initStores(app, { namespace });
|
2024-05-24 23:11:03 +08:00
|
|
|
|
2024-07-30 21:05:03 +08:00
|
|
|
// 安装权限指令
|
2024-07-30 21:10:28 +08:00
|
|
|
registerAccessDirective(app);
|
2024-07-30 21:05:03 +08:00
|
|
|
|
2024-05-24 23:11:03 +08:00
|
|
|
// 配置路由及路由守卫
|
|
|
|
app.use(router);
|
|
|
|
|
2024-11-05 13:58:56 +08:00
|
|
|
// 动态更新标题
|
|
|
|
watchEffect(() => {
|
|
|
|
if (preferences.app.dynamicTitle) {
|
|
|
|
const routeTitle = router.currentRoute.value.meta?.title;
|
|
|
|
const pageTitle =
|
|
|
|
(routeTitle ? `${$t(routeTitle)} - ` : '') + preferences.app.name;
|
|
|
|
useTitle(pageTitle);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2024-05-24 23:11:03 +08:00
|
|
|
app.mount('#app');
|
|
|
|
}
|
|
|
|
|
|
|
|
export { bootstrap };
|