main.ts 1.2 KB
Newer Older
陈文彬 已提交
1
import { createApp } from 'vue';
V
vben 已提交
2
import App from './App.vue';
V
vben 已提交
3

陈文彬 已提交
4 5
import router, { setupRouter } from '/@/router';
import { setupStore } from '/@/store';
V
vben 已提交
6
import { setupErrorHandle } from '/@/logics/error-handle';
V
vben 已提交
7
import { setupGlobDirectives } from '/@/directives';
V
vben 已提交
8
import { setupI18n } from '/@/locales/setupI18n';
陈文彬 已提交
9
import { setupProdMockServer } from '../mock/_createProductionServer';
V
vben 已提交
10 11

import { registerGlobComp } from '/@/components/registerGlobComp';
V
vben 已提交
12

V
vben 已提交
13 14
import { isDevMode, isProdMode, isUseMock } from '/@/utils/env';

陈文彬 已提交
15 16 17 18
import '/@/design/index.less';

const app = createApp(App);

V
vben 已提交
19 20
registerGlobComp(app);

V
vben 已提交
21 22
// Multilingual configuration
setupI18n(app);
V
vben 已提交
23
// Configure routing
陈文彬 已提交
24
setupRouter(app);
V
vben 已提交
25 26

// Configure vuex store
陈文彬 已提交
27 28
setupStore(app);

V
vben 已提交
29 30
// Register global directive
setupGlobDirectives(app);
陈文彬 已提交
31

V
vben 已提交
32
// Configure global error handling
V
vben 已提交
33 34
setupErrorHandle(app);

V
vben 已提交
35
// Mount when the route is ready
陈文彬 已提交
36
router.isReady().then(() => {
37
  app.mount('#app', true);
陈文彬 已提交
38 39
});

V
vben 已提交
40
// The development environment takes effect
陈文彬 已提交
41 42 43 44 45
if (isDevMode()) {
  app.config.performance = true;
  window.__APP__ = app;
}

V
vben 已提交
46
// If you do not need to setting the mock service in the production environment, you can comment the code
陈文彬 已提交
47 48 49
if (isProdMode() && isUseMock()) {
  setupProdMockServer();
}