<script setup lang="ts">
import { ref, onMounted, onUnmounted, reactive, toRefs } from "vue";
import userHead from '@/assets/images/chatVersion/userHead.png'
import robotHead from '@/assets/images/chatVersion/robotHead.png'
import { useI18n } from 'vue-i18n'
const { t: $t } = useI18n()

const props = defineProps({
	type: {
		type: String,
		default: 'user'
	},
	chatDetail: {
		type: Object,
		default: () => ({
			content:'',
			createTime:'',
			image_url:'',
		})
	},
})
//const emit = defineEmits([
//])
let data = reactive({
})
onMounted(()=>{
})
onUnmounted(()=>{
}) 
defineExpose({})
const {} = toRefs(data);
</script>
<template>
	<div class="ChatHistory">
		<div class="titleInfo">
			<div class="userInfo">
				<img :src="type == 'user'? userHead:robotHead" alt="">
				<span>{{ type == 'user'? $t('VersionTree.input'): $t('VersionTree.sketch') }}</span>
			</div>
			<div class="time">
				<span>{{ new Date(chatDetail.createTime * 1000).toLocaleString() }}</span>
			</div>
		</div>
		<div class="infoTitle">{{ type == 'user'? $t('VersionTree.userRequest'): $t('VersionTree.generateResult') }}</div>
		<div class="history">
			<span>{{ chatDetail.content }}</span>
			<img v-if="chatDetail.image_url" :src="chatDetail.image_url" alt="">
		</div>
	</div>
</template>
<style lang="less" scoped>
	.ChatHistory{
		width: 100%;
		height: 100%;
		position: relative;
		display: flex;
		flex-direction: column;
		> .titleInfo{
			height: 2.4rem;
			display: flex;
			justify-content: space-between;
			
			> .userInfo{
				display: flex;
				align-items: center;
				> img{
					margin-right: .2rem;
				}
				> span{
					font-family: 'SemiBold';
					font-weight: 600;
					font-size: 1.4rem;
					line-height: 2rem;
					color: #000;
					opacity: .5;
				}
			}
			> .time{
				font-family: 'SemiBold';
				font-weight: 600;
				font-size: 1.4rem;
				line-height: 2rem;
				opacity: .5;
			}
		}
		> .infoTitle{
			margin-top: .6rem;
			font-size: 1.2rem;
			line-height: 2rem;
			margin-left: 3rem;
		}
		> .history{
			margin-top: .8rem;
			font-family: 'Regular';
			font-weight: 400;
			font-size: 1.2rem;
			line-height: 1.4rem;
			letter-spacing: Letter Spacing;
			flex: 1;
			overflow-y: auto;
			margin-left: 3rem;
			> span{

			}
			> img{
				width: 100%;
				height: auto;
				margin-top: 1.2rem;
				border-radius: 1.3rem;
				border: 1px solid #C9C9C9;
			}
			&::-webkit-scrollbar {
				width: 4px;
			}
			&::-webkit-scrollbar-thumb {
				border-radius: 4px;
				background: #ababab;
			}
			&::-webkit-scrollbar-track {
				border-radius: 4px;
				background: #d9d9d9;
			}
		} 
	}
</style>