<template>
  <!-- 公告 -->
  <el-dialog v-model="visible" :show-close="canClose()" width="500" :close-on-click-modal="false" @close="close"
    :close-on-press-escape="false">
    <template #header>
      <div class="my-header">
        <div style="color: white;">{{ title }}</div>
      </div>
    </template>
    <div v-html="content" style="padding: 12px;height: 500px;"></div>
  </el-dialog>
</template>
<script>
import { getCurrentInstance, toRefs, onMounted } from 'vue'
import { ElDialog } from 'element-plus';
import auth from '@/plugins/auth'
import 'element-plus/theme-chalk/el-dialog.css'; // 引入 el-dialog 的样式
import 'element-plus/theme-chalk/el-button.css';
import useSettingsStore from '@/store/modules/settings'
// import { ElDialog } from 'element-plus';
export default {
  name: 'Notification',
  components: {
    ElDialog
  },
  props: {
    title: {
      type: String,
      default: ''
    },
    content: {
      type: String,
      default: ''
    }
  },
  setup() {
    const visible = ref(false)
    onMounted(() => {
      visible.value = true
    })
    const open = () => {
      visible.value = true
    }
    const close = () => {
      useSettingsStore().setCloseNotification(true)
    }
    const canClose = () => {
      if (auth.hasPermi('business:notification:close')) {
        return true
      }
      return false
    }
    return { visible, canClose, open, close }
  }
}

// // import emitter from '../../eventBus';
// const props = defineProps({
//   title: {
//     type: 'String',
//     default: ''
//   },
//   content: {
//     type: 'String',
//     default: ''
//   }
// });
// const { title, content } = toRefs(props)
// const visible = ref(false)
// const close = () => {
//   visible.value = false
// }
// onMounted(() => {
//   // console.log('mounted notification')
//   // console.log(emitter)
//   // emitter.on('show-dialog', open);
//   // const instance = getCurrentInstance().appContext.app
//   // instance.config.globalProperties.$notificate = { openForUpdate }
// });

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

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