<template>
  <!-- 公告 -->
  <el-dialog v-model="visible" :show-close="showClose" width="500" :close-on-click-modal="false"
    :close-on-press-escape="false">
    <template #header>
      <div class="my-header">
        <div style="color: white;">{{ title }}</div>
      </div>
    </template>
    <div style="padding: 12px;height: 500px;overflow: auto;">
      <div v-html="content"></div>
    </div>

  </el-dialog>
</template>
<script setup>
import { getCurrentInstance } from 'vue'

// import emitter from '../../eventBus';
const title = ref('测试公告')
const content = ref('测试公告内容')
const visible = ref(false)
const showClose = ref(true)
const open = (item) => {
  console.log('notification show')
  title.value = item.title
  content.value = item.content
  visible.value = true
}
const openForUpdate = (item) => {
  title.value = item.title
  content.value = item.updateContent
  visible.value = true
  showClose.value = false
}
const close = () => {
  visible.value = false
}
onMounted(() => {
  // console.log('mounted notification')
  // console.log(emitter)
  // emitter.on('show-dialog', open);
  const instance = getCurrentInstance().appContext.app
  // app.config.globalProperties.$notificate = { openForUpdate }
});

onUnmounted(() => {
  // emitter.off('show-dialog');
});

defineExpose({
  open,
  openForUpdate
})
</script>