import '../utils/polyfill'
import 'vue-slider-component/theme/default.css'
import Vue from 'vue'
import VueSlider from 'vue-slider-component'
import {
    Alert,
    Confirm,
    Tips
} from '../components/shared/message'
import SideSetting from '../components/layout/SideSetting'
import clickoutside from './v-clickoutside'
import clickwindow from './v-clickwindow'
import config from '../config'
import { http } from '../utils/request'
import bus from '../utils/eventbus'

Vue.prototype.$bus = bus
Vue.prototype.$http = http
Vue.prototype.$staticURL = config.getStaticResource.bind(config)

Vue.mixin({
    components: {
        VueSlider,
        SideSetting
    },
    directives: {
        'clickoutside': clickoutside,
        'clickwindow': clickwindow
    },
    data() {
        return {
            
        }
    },
    methods: {
        $alert(data = {}) {
            let instance = new Alert({
                data
            }).$mount()

            document.body.appendChild(instance.$el)

            Vue.nextTick(() => {
                instance.show = true
            })
        },
        $confirm(data = {}) {
            let instance = new Confirm({
                data
            }).$mount()

            document.body.appendChild(instance.$el)

            Vue.nextTick(() => {
                instance.show = true
            })
        },
        $tips(data = {}) {
            let instance = new Tips({
                data
            }).$mount()

            document.body.appendChild(instance.$el)

            Vue.nextTick(() => {
                instance.show = true
            })
        },
        $getStaticResource(url) {
            return config.getStaticResource(url)
        }
    }
})