import Vue from 'vue';
import App from './App';
import router from './router';
import store from './store';
import ElementUI from 'element-ui';
import '@/style/element-variables.scss';
import ChinaArea from '@mlinquan/china-area';
import { formatDict } from '@utils/global';
import AuthButton from '@comp/auth-button';
import moment from 'moment';
import BaseTable from '@comp/base-table';
import FormMaking from 'form-making';
import VueParticles from 'vue-particles';
import 'form-making/dist/FormMaking.css';

import treeSelect from '@riophae/vue-treeselect';
import '@riophae/vue-treeselect/dist/vue-treeselect.css';
import '@/style/common.less';
import '@/style/layout.less';
import '@/style/theme.less';

import dataV from '@jiaminghi/data-view';

Vue.use(dataV);
Vue.use(ElementUI);
Vue.use(FormMaking);
Vue.use(VueParticles);

Vue.component('el-auth-button', AuthButton);
Vue.component('baseTable', BaseTable);
Vue.component('TreeSelect', treeSelect);
Vue.config.productionTip = false;

Vue.prototype.$search = {
  current: 1,
  size: 10,
  total: 0
};

Vue.prototype.$dialogSearch = {
  current: 1,
  size: 5,
  total: 0
};

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

window.document.title = process.env.VUE_APP_TITLE;

const cnArea = new ChinaArea({
  got: true,
  format: {
    key: 'value',
    value: 'label',
    children: 'children'
  }
});
Vue.prototype.$cnArea = cnArea;
Vue.prototype.$region = cnArea.region();

Vue.filter('globalFormatDict', function (value, dictName) {
  return formatDict(store.getters.dict[dictName], value);
});

Vue.filter('globalFormatDate', function (value, formatter) {
  return moment(value).format(formatter);
});
