import { service } from '@erayt/titanOne-vue/lib/main.js';

import routeConfig from '../config/route.config';
import modules from './store/modules';
import getters from './store/getters';
import rxd from 'vue-dynamic';
import 'vue-dynamic/dist/Dynamic.css';
import 'vue-dynamic-theme';
import ECharts from './plugins/echarts';
import Vue from 'vue';
import { messages } from './lang';
import { message } from './utils/elementUtils';
import { appInit } from './utils';
import Sdp from './sdp';
import apis from '@/api';
import { confirmAction } from './utils';
import Views from '@erayt/vue-sdp';
const custservice = Eui.service;
Views.install(custservice.Vue, {
  locale: {},
  i18n: function(key, value) {
    return Views.getMessage(key, custservice.i18n.t.bind(custservice.i18n));
  },
});

rxd.titan.init();

appInit();
const EventBus = new Vue();
Vue.prototype.$bus = EventBus;
Vue.prototype.$apis = apis;
Vue.config.devtools = process.env.NODE_ENV === 'development';

Vue.use(ECharts);
Vue.prototype.$message = message;
Vue.prototype.$confirmAction = confirmAction;
Vue.prototype.$buttonSize = 'small';
// sdp pageLimit 参数默认设置
Vue.prototype.$SdpPageSize = 20;
// Vue.prototype.$SdpPageSizes = [10, 20, 50, 100];

Vue.prototype.$SdpFunction = Sdp;

import DcsDetailsDialogPlugin from './plugins/dcsDetailsDialogPlugin.js';
Vue.use(DcsDetailsDialogPlugin);

service.registerApplication('rcs_5.0', {
  routeConfig,
  getters,
  modules,
  i18n: messages,
});

// alibaba矢量图标库
import './assets/iconfont/iconfont.css';
import './assets/iconfont/iconfont.js';
import IconFont from '@/components/iconFont';
Vue.component('IconFont', IconFont);

import PublicTable from '@/components/table';
Vue.component('PublicTable', PublicTable);

// main.js 或插件文件中
// Vue.directive('local-storage-watch', {
//   bind(el, binding) {
//     const callback = binding.value;

//     // 监听原生storage事件
//     window.addEventListener('storage', (event) => {
//       if (event.key === binding.arg) {
//         callback(event.newValue, event.oldValue);
//       }
//     });

//     // 监听自定义事件（当前页面修改）
//     document.addEventListener('localStorageChanged', (event) => {
//       if (event.key === binding.arg) {
//         callback(event.newValue, localStorage.getItem(event.key));
//       }
//     });
//   },
// });
service.load();
