// import Vue from 'vue'
import Modal from './modal.vue';
import i18n from '@/util/lang/lang'

Modal.install = function (Vue, store) {
    const modalConstructor = Vue.extend(Modal)
    let instance;

    Vue.prototype.$showRule = () => {
        if (instance) {
            document.body.removeChild(instance.$el)
            instance = null
        }

        instance = new modalConstructor({
            el: document.createElement('div'),
            computed: {
                $store() { return store }
            },
            data() {
                return {
                    modalShow: true,
                }
            },
            i18n
        })

        document.body.appendChild(instance.$el)
    }

    Vue.prototype.$showFair = () => {
        if (instance) {
            document.body.removeChild(instance.$el)
            instance = null
        }

        instance = new modalConstructor({
            el: document.createElement('div'),
            computed: {
                $store() { return store }
            },
            data() {
                return {
                    fairShow: true
                }
            },
            i18n
        })

        document.body.appendChild(instance.$el)
    }

    Vue.prototype.$showCount = () => {
        if (instance) {
            document.body.removeChild(instance.$el)
            instance = null
        }

        instance = new modalConstructor({
            el: document.createElement('div'),
            computed: {
                $store() { return store }
            },
            data() {
                return {
                    countShow: true
                }
            },
            i18n
        })

        document.body.appendChild(instance.$el)
    }

    Vue.prototype.$showGt = () => {
        if (instance) {
            document.body.removeChild(instance.$el)
            instance = null
        }

        instance = new modalConstructor({
            el: document.createElement('div'),
            computed: {
                $store() { return store }
            },
            data() {
                return {
                    gtShow: true
                }
            },
            i18n
        })

        document.body.appendChild(instance.$el)
    }
}

export default Modal




