/** ele admin pro license by http://eleadmin.com */
import NProgress from 'nprogress';
import Antd from 'ant-design-vue';
import EleAvatarList from './ele-avatar-list';
import EleEditTag from './ele-edit-tag';
import EleProLayout from './ele-pro-layout';
import EleProTable from './ele-pro-table';
import EleProTableTools from './ele-pro-table-tools';
import EleTag from './ele-tag';
import EleToolbar from './ele-toolbar';
import * as util from './util.js';
import messageLoading from './message-loading.js';
import {menuToRoutes, formatMenus} from './menu-util.js';

export {
  EleAvatarList,
  EleEditTag,
  EleProLayout,
  EleProTable,
  EleProTableTools,
  EleTag,
  EleToolbar,
  messageLoading,
  menuToRoutes,
  formatMenus,
  util
}

export default {
  install: function (app, opt) {
    // 配置nprogress
    NProgress.configure(Object.assign({
      speed: 200,
      minimum: 0.02,
      trickleRate: 0.1,
      trickleSpeed: 200,
      showSpinner: false
    }, opt ? opt.nProgress : null));

    // 安装antd
    app.use(Antd);

    // 添加全局属性
    app.config.globalProperties.$ELEADMIN = {
      request: opt ? opt.request : null,
      response: opt ? opt.response : null
    };
    app.config.globalProperties.$util = util;
    app.config.globalProperties.$messageLoading = messageLoading;

    // 注册全局组件
    app.component(EleAvatarList.name, EleAvatarList);
    app.component(EleEditTag.name, EleEditTag);
    app.component(EleProLayout.name, EleProLayout);
    app.component(EleProTable.name, EleProTable);
    app.component(EleProTableTools.name, EleProTableTools);
    app.component(EleTag.name, EleTag);
    app.component(EleToolbar.name, EleToolbar);
  }
}
