main.js 2.38 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';
wb-ct393452's avatar
wb-ct393452 committed
9
import App from './App.vue';
10
import 'tailwindcss/tailwind.css';
wb-ct393452's avatar
wb-ct393452 committed
11 12 13 14 15 16 17

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';
18
import { loadResponseInterceptor } from './utils/requestUtil';
wb-ct393452's avatar
wb-ct393452 committed
19

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

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

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

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

//装载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({
46 47 48
    locale: localeLang,
    fallbackLocale: fallbackLang,
    silentFallbackWarn: true,
wb-ct393452's avatar
wb-ct393452 committed
49
});
50

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

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

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

67 68 69 70 71 72 73 74 75
// this.$notification.open({
//     message: 'Notification Title',
//     description:
//         'This is the content of the notification. This is the content of the notification. This is the content of the notification.',
//     onClick: () => {
//         console.log('Notification Clicked!');
//     },
// });

水落(YangLei)'s avatar
水落(YangLei) committed
76
loadResponseInterceptor({ router });
wb-ct393452's avatar
wb-ct393452 committed
77 78

new Vue({
79 80 81 82
    router,
    store,
    i18n,
    render: h => h(App),
wb-ct393452's avatar
wb-ct393452 committed
83
}).$mount('#app');