main.ts 1.3 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 { setupAntd } from '/@/setup/ant-design-vue';
V
vben 已提交
7
import { setupErrorHandle } from '/@/setup/error-handle';
V
vben 已提交
8
import { setupGlobDirectives } from '/@/directives';
V
vben 已提交
9
import { setupI18n } from '/@/locales/setupI18n';
陈文彬 已提交
10
import { setupProdMockServer } from '../mock/_createProductionServer';
V
vben 已提交
11 12

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

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

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

const app = createApp(App);

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

V
vben 已提交
22
// Configure component library
陈文彬 已提交
23
setupAntd(app);
V
vben 已提交
24

V
vben 已提交
25 26 27
// Multilingual configuration
setupI18n(app);

V
vben 已提交
28
// Configure routing
陈文彬 已提交
29
setupRouter(app);
V
vben 已提交
30 31

// Configure vuex store
陈文彬 已提交
32 33
setupStore(app);

V
vben 已提交
34 35
// Register global directive
setupGlobDirectives(app);
陈文彬 已提交
36

V
vben 已提交
37
// Configure global error handling
V
vben 已提交
38 39
setupErrorHandle(app);

V
vben 已提交
40
// Mount when the route is ready
陈文彬 已提交
41
router.isReady().then(() => {
42
  app.mount('#app', true);
陈文彬 已提交
43 44
});

V
vben 已提交
45
// The development environment takes effect
陈文彬 已提交
46 47 48 49 50
if (isDevMode()) {
  app.config.performance = true;
  window.__APP__ = app;
}

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