<template>
	<el-popover
		placement="bottom"
		title=""
		trigger="click"
		content=""
		width="300"
		v-bind="$attrs"
		:visible="show"
	>
		<template #reference>
			<slot></slot>
		</template>
		<template #default>
			<div class="refreshBox">{{refreshDom}}</div>
		</template>
	</el-popover>
</template>

<script>
import {eventBus} from "@/utils/eventBus";

export default {
	name: "emailSync",
	props:{
		size:{type: String, default: "small" },
		show:{type: Boolean, default: false},
		text:{type: String},
	},
	watch:{
		text: {
			handler (v) {
				this.refreshDom = v;
			},
			immediate:true,
			deep:true,
		}
	},
	data(){
		return{
			refreshDom:this.text,
		}
	},
	mounted() {
		// 获取新消息
		eventBus.$on('sockBack', this.getWsResult);
	},
	unmounted() {
		eventBus.$off('sockBack', this.getWsResult);
	},
	methods:{
		getWsResult(res){
			if(res.data && (res.data.type == 16)){
				this.$emit('updateSync', res.data);
			}
		},
	}
}
</script>

<style scoped>

</style>
