<template>
  <!-- 消息页面 -->
  <div class="message">
    <div style="height: 100%">
      <el-splitter>
        <el-splitter-panel size="17%" min="17%" max="25%">
          <!-- 会话列表 -->
          <div class="demo-panel">
            <div
              v-infinite-scroll="load"
              infinite-scroll-distance="100px"
              class="chatList"
              style="overflow: auto"
            >
              <div class="chatItem" v-for="(item, index) in chatList" :key="index">
                <div class="Avatar"></div>
                <div class="chatContent">
                  <div class="PersonalInfo">
                    <div class="name">名称</div>
                    <div class="time">07-29 14:00</div>
                  </div>
                  <div class="chatText">最后一条消息</div>
                </div>
              </div>
            </div>
          </div>
        </el-splitter-panel>
        <el-splitter-panel>
          <el-splitter layout="vertical">
            <el-splitter-panel>
              <!-- 消息列表 -->
              <div class="demo-panel"></div>
            </el-splitter-panel>
            <el-splitter-panel size="20%" min="20%" max="40%">
              <!-- 输入框 -->
              <div class="demo-panel">
                <div class="inputBox">
                  <div class="Console">
                  <div class="Console-content">
                    
                  </div>
                  </div>
                  <div class="input">
                    <textarea 
                      v-model="textarea"
                      class="textarea"
                      style="width: 100%; height: 100%"
                    />
                  </div>
                </div>
              </div>
            </el-splitter-panel>
          </el-splitter>
        </el-splitter-panel>
      </el-splitter>
    </div>
  </div>
</template>

<script setup>
import {
  ref, // 响应式基础
  watch, // 侦听器
  onMounted, // 组件挂载完成后执行
  onUpdated, // 组件更新后执行
  onUnmounted, // 组件销毁前执行
} from "vue";
const refname = ref("");
const textarea = ref(""); // 输入框内容
const chatList = ref([
  {},
  {},
  {},
  {},
  {},
  {},
  {},
  {},
  {},
  {},
  {},
  {},
  {},
  {},
  {},  
  {},
  {},
  {},
  {},
  {},
  {},
  {},
  {},
  {},
  {},
]);

function load() {
  console.log("加载更多",textarea.value);
  
} // 加载更多

watch(refname, async (newQuestion, oldQuestion) => {
  // 变化后执行
});
onMounted(() => {
  // 组件挂载完成后执行
});
onUpdated(() => {
  // 组件更新后执行
});
onUnmounted(() => {
  // 组件销毁前执行
});
</script>

<style scoped lang="less">
.message {
  width: 100%;
  height: 100%;
  border-radius: 16px;
  background-color: #ffffff;
}
.demo-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}
.chatList {
  width: 100%;
  height: 100%;
  background-color: #ffffff;
  border-top-left-radius: 16px;
  border-bottom-left-radius: 16px;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
.chatItem {
  width: 100%;
  height: 70px;
  background-color: #ffffff;
  display: flex;
  align-items: center;
}
.chatItem:hover {
  background-color: #f5f5f5;
}
.Avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  margin-left: 10px;
  background-color: #f5f5f5;
}
.chatContent {
  margin-left: 10px;
  width: calc(100% - 80px);
  height: 60%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.PersonalInfo {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.name {
  width: 50%;
  font-size: 14px;
  color: @font-color;
  font-weight: bold;
  white-space: nowrap; /* 单行显示 */
  overflow: hidden;
  text-overflow: ellipsis; /* 显示省略号 */
}
.time {
  font-size: 12px;
  color: @Prompt-text-color;
}
.chatText {
  font-size: 10px;
  color: @font-color;
  width: 100%;
  white-space: nowrap; /* 单行显示 */
  overflow: hidden;
  text-overflow: ellipsis; /* 显示省略号 */
}
.inputBox {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.Console {
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.Console-content{
  width: 98%;
  height: 100%;
}
.input {
  width: 98%;
  height: calc(100% - 70px);
}
.textarea{
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  overflow: hidden;
  background-color:#ffffff00;
  resize:none;
}
</style>
