import MessageComp from './Index.vue'
const Message = {};
Message.install = function (Vue) {
    const MessageConstructor = Vue.extend(MessageComp);
    const instance = new MessageConstructor();
    instance.$mount(document.createElement('div'));
    document.body.appendChild(instance.$el);
    // 通过Vue的原型注册一个方法
    // 让所有实例共享这个方法
    Vue.prototype.$message = ({msg,type,duration=1500}) => {
        window.clearTimeout(instance.timer);
        if(msg==undefined){
            instance.visible = false;
            return;
        }
        instance.msg = msg;
        instance.type=type;
        instance.visible = true;
        instance.timer=window.setTimeout(() => {
            instance.visible = false;
        }, duration);
    };
}
export default Message;