<template>
  <div id="chat">
    <div id="contents">
      <div class="chat-item" v-for="(i, index) in chatList" :key="index">
        <div class="chat-msg">
          <span :class="{ my: i.UserId == user_info.UserId }" class="chat-name"> {{ i.Nickname }} &nbsp;</span>
          <span class="chat-content"> {{ i.text }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { onMounted, watch, defineProps, defineEmits, ref, nextTick } from "vue";

const props = defineProps({
  user_info: {
    type: Object,
    default: {},
  },
  chatList: {
    type: Array,
    default: [],
  },
});
</script>

<style scoped lang="scss">
#chat {
  // width: 7.03rem;
  width: 50%;
  max-height: 4.58rem;
  overflow: auto;
  position: fixed;
  left: 0.44rem;
  bottom: 2.83rem;
  .chat-item {
  }
  .chat-msg {
    width: auto;
    border-radius: 0.44rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.17rem 0.28rem;
    box-sizing: border-box;

    display: inline-block;
    // margin-bottom: 0.17rem;
    margin-bottom: 0.1rem;
    .chat-name {
      color: #70bbff;
      font-size: 0.28rem;
      &.my {
        color: #ff9a6a;
      }
    }
    .chat-content {
      color: #fff;
      font-size: 0.28rem;
      word-break: break-all;
    }
  }
  &::-webkit-scrollbar {
    display: none;
  }
}
</style>
