import Vue from "vue";
import App from "./App.vue";
import store from "./store";
import i18n from "./util/lang/lang";
import toastRegistry from "./plugin/toast/index";
import loadingRegistry from "./plugin/loading/index";
import loginPlugin from "./plugin/login/index";
import bridgePlugin from "./plugin/bridge/bridge";
import modalCharge from "@/components/popup/modal";
import VueClipboard from "vue-clipboard2";

import popupCharge from "@eosget/eosget-components/popup/charge/";
import popupVip from "@eosget/eosget-components/popup/vip/";
import balanceDetail from "@eosget/eosget-components/popup/detail/";
import popupValidate from "@/components/popup/validate";

Vue.config.productionTip = false;

Vue.use(VueClipboard);
Vue.use(toastRegistry);
Vue.use(loadingRegistry);
Vue.use(loginPlugin, store);
Vue.use(bridgePlugin, store);
Vue.use(modalCharge, store);

Vue.use(popupCharge, store);
Vue.use(popupVip);
Vue.use(balanceDetail, store);
Vue.use(popupValidate, store);

const EOS_VUE = (window.EOS_VUE = new Vue({
    render: h => h(App),
    store,
    i18n
}).$mount("#app"));

//监听postmessage
window.addEventListener(
    "message",
    function(ev) {
        if (ev.data.func) {
            let func = EOS_VUE[ev.data.func];
            let options = ev.data.options;
            func && func.apply(EOS_VUE, options);
        }
    },
    false
);
