<script setup>
// 信息提示窗口

import {inject, onMounted, ref} from "vue";
import TMessage from "@/components/ui/TMessage.vue";

const Tea = inject("$Tea")

const props = defineProps(["code"])
const {visible} = (function () {
	return {
		visible: ref(false)
	}
})()

onMounted(() => {
	Tea.action("/ui/showTip")
		.params({
			code: props.code
		})
		.success(function (resp) {
			visible.value = resp.data.visible
		})
		.post()
})

const close = function () {
	visible.value = false
	Tea.action("/ui/hideTip")
		.params({
			code: props.code
		})
		.post()
}

</script>

<template>
	<TMessage class="mb-4" icon="pi pi-info-circle" v-if="visible">
		<div class="absolute -mt-3 left-10 right-0">
			<slot></slot>
			<a href="" title="取消" @click.prevent="close" class="absolute right-4"><i class="pi pi-remove" ></i></a>
		</div>
	</TMessage>
</template>

<style scoped lang="postcss">

</style>