vue-vben-admin/src/main.ts

60 lines
1.6 KiB
TypeScript
Raw Normal View History

2021-02-17 22:07:22 +08:00
import '/@/design/index.less';
2021-08-24 00:28:53 +08:00
import 'virtual:windi-base.css';
import 'virtual:windi-components.css';
import 'virtual:windi-utilities.css';
// Register icon sprite
import 'virtual:svg-icons-register';
2020-11-26 21:19:39 +08:00
import App from './App.vue';
2021-06-07 21:30:27 +08:00
import { createApp } from 'vue';
import { initAppConfigStore } from '/@/logics/initAppConfig';
import { setupErrorHandle } from '/@/logics/error-handle';
2021-06-07 21:30:27 +08:00
import { router, setupRouter } from '/@/router';
2021-04-10 19:25:49 +08:00
import { setupRouterGuard } from '/@/router/guard';
2020-09-28 20:19:10 +08:00
import { setupStore } from '/@/store';
2020-12-21 22:34:07 +08:00
import { setupGlobDirectives } from '/@/directives';
2021-01-09 23:28:52 +08:00
import { setupI18n } from '/@/locales/setupI18n';
import { registerGlobComp } from '/@/components/registerGlobComp';
2020-10-15 21:12:38 +08:00
2021-08-24 22:32:43 +08:00
// Importing on demand in local development will increase the number of browser requests by around 20%.
// This may slow down the browser refresh speed.
// Therefore, only enable on-demand importing in production environments .
2021-04-01 22:34:31 +08:00
if (import.meta.env.DEV) {
import('ant-design-vue/dist/antd.less');
}
2021-06-01 21:30:56 +08:00
async function bootstrap() {
const app = createApp(App);
2021-04-10 19:25:49 +08:00
// Configure store
2021-04-10 19:25:49 +08:00
setupStore(app);
2021-04-13 21:43:10 +08:00
// Initialize internal system configuration
initAppConfigStore();
// Register global components
registerGlobComp(app);
2021-01-09 23:28:52 +08:00
2021-03-23 00:21:09 +08:00
// Multilingual configuration
2021-08-24 22:32:43 +08:00
// Asynchronous case: language files may be obtained from the server side
2021-03-23 00:21:09 +08:00
await setupI18n(app);
// Configure routing
setupRouter(app);
2021-01-23 21:10:00 +08:00
2021-04-10 19:25:49 +08:00
// router-guard
setupRouterGuard(router);
2020-11-18 22:41:59 +08:00
// Register global directive
setupGlobDirectives(app);
2020-09-28 20:19:10 +08:00
// Configure global error handling
setupErrorHandle(app);
2020-09-28 20:19:10 +08:00
2021-03-26 21:16:08 +08:00
// https://next.router.vuejs.org/api/#isready
2021-08-24 22:32:43 +08:00
// await router.isReady();
2020-10-18 21:55:21 +08:00
2021-08-24 22:41:48 +08:00
app.mount('#app');
2021-06-01 21:30:56 +08:00
}
2021-08-17 22:15:27 +08:00
bootstrap();