main.js 2.16 KB
Newer Older
wb-ct393452's avatar
wb-ct393452 committed
1 2 3 4 5 6 7
import Vue from 'vue';
import Vuex from 'vuex';
import Antd from 'ant-design-vue';
import Viser from 'viser-vue';
import Router from 'vue-router';
import { initRouter } from './router';
import VueI18n from 'vue-i18n';
8
import { accountModule, settingModule } from './pages/frame/store';
9
import globalStore from '@/store';
wb-ct393452's avatar
wb-ct393452 committed
10
import App from './App.vue';
11
import 'tailwindcss/tailwind.css';
wb-ct393452's avatar
wb-ct393452 committed
12 13 14 15 16 17 18

import 'animate.css/source/animate.css';
import './theme/index.less';
import Plugins from './plugins';

import { loadRoutes, loadGuards, setAppOptions } from './utils/routerUtil';
import guards from './router/guards';
19
import { loadResponseInterceptor } from './utils/requestUtil';
wb-ct393452's avatar
wb-ct393452 committed
20

21
// import '@/mock';
wb-ct393452's avatar
wb-ct393452 committed
22 23
import 'moment/locale/zh-cn';

24
//设置为非生产提示
wb-ct393452's avatar
wb-ct393452 committed
25 26 27
Vue.config.productionTip = false;

//装载Vuex控件
28 29
Vue.use(Vuex);
//加载 框架的module包括 命名空间accountModule,settingModule
wb-ct393452's avatar
wb-ct393452 committed
30
const store = new Vuex.Store({
31
    ...globalStore,
32
    modules: { accountModule, settingModule },
wb-ct393452's avatar
wb-ct393452 committed
33 34 35 36 37 38
});

//装载vue-router控件 如果开发时 不用动态可直接修改这里 isAsynRount=false
Vue.use(Router);
const isAsynRount = store.state.settingModule.asyncRoutes;
const options = initRouter(isAsynRount);
水落(YangLei)'s avatar
水落(YangLei) committed
39
const router = new Router(options);
wb-ct393452's avatar
wb-ct393452 committed
40 41 42 43 44 45 46 47

//装载vue-i18n控件 如果语言优先级 请直接修改这里localeLang和fallbackLang
Vue.use(VueI18n);
//defalt 'CN'
const localeLang = store.state.settingModule.lang;
//default'EN'
const fallbackLang = store.state.settingModule.fallbackLang;
const i18n = new VueI18n({
48 49 50
    locale: localeLang,
    fallbackLocale: fallbackLang,
    silentFallbackWarn: true,
wb-ct393452's avatar
wb-ct393452 committed
51
});
52

wb-ct393452's avatar
wb-ct393452 committed
53 54 55 56 57 58 59 60 61 62
//装载antd控件
Vue.use(Antd);
//装载Viser;
Vue.use(Viser);
//装载所有插件 VueI18nPlugin,AuthorityPlugin,TabsPagePlugin
Vue.use(Plugins);

//启动引导方法应用启动时需要执行的操作放在这里
//设置应用配置
setAppOptions({ router, store, i18n });
63

wb-ct393452's avatar
wb-ct393452 committed
64 65 66 67 68
// 加载路由
loadRoutes();
// 加载路由守卫
loadGuards(guards, { router, store, i18n, message: Vue.prototype.$message });

水落(YangLei)'s avatar
水落(YangLei) committed
69
loadResponseInterceptor({ router });
wb-ct393452's avatar
wb-ct393452 committed
70

水落(YangLei)'s avatar
水落(YangLei) committed
71 72
Vue.prototype.$fileUrl = 'http://platform.kuopu.net:9300/';

wb-ct393452's avatar
wb-ct393452 committed
73
new Vue({
74 75 76 77
    router,
    store,
    i18n,
    render: h => h(App),
wb-ct393452's avatar
wb-ct393452 committed
78
}).$mount('#app');