vue-vben-admin/src/main.ts

59 lines
1.3 KiB
TypeScript
Raw Normal View History

2020-09-28 20:19:10 +08:00
import { createApp } from 'vue';
2020-10-15 21:12:38 +08:00
2020-09-28 20:19:10 +08:00
import router, { setupRouter } from '/@/router';
import { setupStore } from '/@/store';
2020-10-15 21:12:38 +08:00
import { setupAntd } from '/@/setup/ant-design-vue';
2020-11-12 22:20:15 +08:00
import { setupErrorHandle } from '/@/setup/error-handle';
2020-11-18 22:41:59 +08:00
import { setupGlobDirectives } from '/@/setup/directives';
import { setupI18n } from '/@/setup/i18n';
2020-09-28 20:19:10 +08:00
import { setupProdMockServer } from '../mock/_createProductionServer';
2020-11-18 22:52:13 +08:00
import { setApp } from '/@/setup/App';
2020-10-15 21:12:38 +08:00
import App from './App.vue';
2020-11-18 22:41:59 +08:00
import { isDevMode, isProdMode, isUseMock } from '/@/utils/env';
2020-09-28 20:19:10 +08:00
import '/@/design/index.less';
import '/@/locales/index';
2020-09-28 20:19:10 +08:00
const app = createApp(App);
2020-11-18 22:41:59 +08:00
// Configure component library
2020-09-28 20:19:10 +08:00
setupAntd(app);
2020-11-18 22:41:59 +08:00
// Multilingual configuration
setupI18n(app);
2020-11-18 22:41:59 +08:00
// Configure routing
2020-09-28 20:19:10 +08:00
setupRouter(app);
2020-11-18 22:41:59 +08:00
// Configure vuex store
2020-09-28 20:19:10 +08:00
setupStore(app);
2020-11-18 22:41:59 +08:00
// Register global directive
setupGlobDirectives(app);
2020-09-28 20:19:10 +08:00
2020-11-18 22:41:59 +08:00
// Configure global error handling
2020-10-18 21:55:21 +08:00
setupErrorHandle(app);
2020-11-18 22:41:59 +08:00
// Mount when the route is ready
2020-09-28 20:19:10 +08:00
router.isReady().then(() => {
app.mount('#app');
});
2020-11-18 22:41:59 +08:00
// The development environment takes effect
2020-09-28 20:19:10 +08:00
if (isDevMode()) {
app.config.performance = true;
window.__APP__ = app;
}
2020-10-29 23:01:11 +08:00
// If you do not need to use the mock service in the production environment, you can comment the code
2020-09-28 20:19:10 +08:00
if (isProdMode() && isUseMock()) {
setupProdMockServer();
}
2020-10-29 23:01:11 +08:00
// Used to share app instances in other modules
setApp(app);