MAIN.ts.ftl 2.3 KB
Newer Older
1 2 3 4 5 6
import Vue from 'vue';
import Vuex from 'vuex';
import VueRouter from 'vue-router';
import App from '@/App.vue';
import ElementUi from 'element-ui';
import ViewUI from 'view-design';
7
import ibizLab from 'ibiz-vue-lib';
8
import axios from "axios";
9 10 11 12 13 14
import { Interceptors } from '@/utils';
import  {Print} from '@/utils/print';
import i18n from '@/locale'

import 'element-ui/lib/theme-chalk/index.css';
import 'view-design/dist/styles/iview.css';
15
import 'ibiz-vue-lib/lib/ibiz-vue-lib.css';
16
import 'font-awesome/css/font-awesome.css';
17
import '@/styles/default.scss';
18

19
import VueAMap from 'vue-amap';
20
// 基于 @VIEW/应用首页视图/MAIN.ts.ftl 生成
21 22 23 24 25 26 27 28
Vue.use(VueAMap);

VueAMap.initAMapApiLoader({
  key: '6ab2751103aea67e817c90a5528181b5',
  plugin: ["AMap.Geolocation","AMap.PlaceSearch","AMap.Geocoder", "AMap.Autocomplete"],
  uiVersion: '1.1'
});

29 30 31 32 33 34 35 36 37 38 39 40 41
// 模拟数据
if (process.env.NODE_ENV === 'development') {
  require('@/mock');
}

const pathToRegExp = require('path-to-regexp');
import { AppComponents } from '@/app-register';
import { PageComponents } from './page-register';
import { UserComponent } from '@/user-register';
import { PortletComponent } from '@/portlet-register';
import store from '@/store';
import router from './router';

42 43
const win: any = window;
win.axios = axios;
44
win.appRouter = router;
45

46 47 48
Vue.config.errorHandler = function (err: any, vm: any, info: any) {
  console.log(err);
}
49

50
Vue.config.productionTip = false;
51
Vue.use(Print);
52
Vue.use(ibizLab);
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
Vue.use(Vuex);
Vue.use(VueRouter);;
Vue.use(ElementUi, {
  i18n: (key: any, value: any) => i18n.t(key, value)
});
Vue.use(ViewUI, {
  i18n: (key: any, value: any) => i18n.t(key, value)
});

// Vue.use(utils);
Vue.prototype.$pathToRegExp = pathToRegExp;
<#--  Vue.use(Print);  -->
Vue.use(AppComponents);
Vue.use(PageComponents);
Vue.use(UserComponent);
Vue.use(PortletComponent);

router.beforeEach((to: any, from: any, next: any) => {
tony001's avatar
tony001 committed
71 72 73 74 75 76 77
  if(sessionStorage.getItem('lockState') && to.path != '/lock'){
    next({ path: '/lock'});
  }else{
    if (to.meta && !to.meta.ignoreAddPage) {
      router.app.$store.commit('addPage', to);
    }
    next();
78 79 80 81 82 83 84 85 86 87 88 89 90 91
  }
});

Interceptors.getInstance(router,store);

const init = async () => {
  new Vue({
      i18n,
      store,
      router,
      render: (h: any) => h(App),
  }).$mount('#app');
};
init();