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';
import { accountModule, settingModule } from './pages/frame/store';
import App from './App.vue';
import 'tailwindcss/tailwind.css';

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';
import { loadResponseInterceptor } from './utils/requestUtil';

// import '@/mock';
import 'moment/locale/zh-cn';

//设置为非生产提示
Vue.config.productionTip = false;

//装载Vuex控件
Vue.use(Vuex);
//加载 框架的module包括 命名空间accountModule，settingModule
const store = new Vuex.Store({
    modules: { accountModule, settingModule },
});

//装载vue-router控件 如果开发时 不用动态可直接修改这里 isAsynRount=false
Vue.use(Router);
const isAsynRount = store.state.settingModule.asyncRoutes;
const options = initRouter(isAsynRount);
const router = new Router({ mode: 'history', ...options });

//装载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({
    locale: localeLang,
    fallbackLocale: fallbackLang,
    silentFallbackWarn: true,
});

//装载antd控件
Vue.use(Antd);
//装载Viser；
Vue.use(Viser);
//装载所有插件 VueI18nPlugin，AuthorityPlugin，TabsPagePlugin
Vue.use(Plugins);

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

// 加载路由
loadRoutes();
// 加载路由守卫
loadGuards(guards, { router, store, i18n, message: Vue.prototype.$message });

// 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!');
//     },
// });

loadResponseInterceptor({ router });

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