zhongshujie
5 天以前 90675cb210f5a2afc4766e6fd091776a14397d48
src/views/Start.vue
@@ -1,468 +1,1600 @@
<template>
  <div class="chat-box">
    <div class="chat-box-content">
      <div class="chat-date">03/15 13:10:00</div>
    <!-- 返回首页标签 -->
    <div class="chat-back-icon" >
      <el-icon :size="25" color="#6e3d3c" @click="handleBackClick()" style="cursor: pointer;">
        <Back />
      </el-icon>
    </div>
    <!-- 聊天框内容容器 -->
    <div class="chat-box-content" ref="messagesContainer">
      <!-- 当前时间显示 -->
      <div class="chat-date">{{ currentTime }}</div>
      <!-- 底部信息展示 -->
      <div class="chat-back-info">
        <!-- 头像 -->
        <div class="back-avator">
          <img src="../assets/images/image2.png" alt="" />
        </div>
        <!-- 基础图书信息 -->
        <div class="base-book-box">
          Hi,我是****图书馆AI智能图书检索助手,帮你轻松检索书籍!试试问我:'有没有关于XX的书?"或“推荐一本XX领域的书'吧!
          Hi,我是陕西省高新区图书馆AI智能图书检索助手,帮你轻松检索书籍!试试问我:“有没有关于XX的书?”或“推荐一本XX领域的书”吧!
        </div>
      </div>
      <!-- 热门问题列表 -->
      <div class="back-item">
        <!-- 热门问题标题 -->
        <div class="back-item-title">
          <img src="../assets/images/redian.png" alt="" />
          <span>热门问题</span>
        </div>
        <!-- 热门问题项 -->
        <ul>
          <li>
          <li class="hot-question" v-for="(item, index) in limitedQuestionList" :key="index"
            @click="handleQuestionClick(item.question)">
            <img src="../assets/images/wenti.png" alt="" />
            <span>图书馆的开闭馆时问是什么?</span>
          </li>
          <li>
            <img src="../assets/images/wenti.png" alt="" />
            <span>超期还书如何处理?</span>
          </li>
          <li>
            <img src="../assets/images/wenti.png" alt="" />
            <span>什么是图书馆罚款?</span>
          </li>
          <li>
            <img src="../assets/images/wenti.png" alt="" />
            <span>借阋图书遗失如何处理?</span>
          </li>
          <li>
            <img src="../assets/images/wenti.png" alt="" />
            <span>如何借阅馆藏图书和期刊?</span>
          </li>
          <li>
            <img src="../assets/images/wenti.png" alt="" />
            <span>读者的借阅期限是多久?</span>
            <span>{{ item.question }}</span>
          </li>
        </ul>
        <div class="chat-change">
        <!-- 换一换按钮 -->
        <div class="chat-change" @click="shuffleQuestions()">
          <img src="../assets/images/shuxin1.png" alt="" />
          <span>换一换</span>
        </div>
      </div>
      <div class="chat-footer">
        <div class="icon-list">
          <img src="../assets/images/liebiao1.png" alt="" />
          <img src="../assets/images/tianjia2.png" alt="" />
        </div>
        <div class="chat-text">
          <el-input type="textarea" :autosize="{ minRows: 2, maxRows: 10 }" placeholder="请输入您的问题"
            v-model="inputValue" />
        </div>
        <div class="select">
          <div class="select-left">
            <div class="select-item">
              <img src="../assets/images/sikao.png" alt="" />
              <span>深度思考(R1)</span>
      <!-- 消息列表 -->
      <div v-for="(item, index) in message" :key="index" class="chat-box-content-item">
        <div v-if="item.type === 'user'" class="chat-date">{{ item.time }}</div>
        <div :class="['message', item.type === 'user' ? 'user-message' : 'assistant-message']">
          <!-- 助手头像 -->
          <el-avatar class="assistant-avatar" :size="screenWidth > 375 ? 60 : 30"
            :src="[item.type === 'user' ? userProfilePicture : assistantAvatar]" />
          <!-- 消息内容 -->
          <div :class="['message-content', item.type === 'user' ? 'user-message-content' : '']">
            <!-- 用户消息 -->
            <div class="user-message-text" v-if="item.type === 'user'" v-html="item.content"></div>
            <!-- AI List消息 -->
            <div :class="['message-text', 'requestText' + index].join(' ')"
              v-if="item.type != 'user' && item.txtType !== 'txt'">
              <p class="message-text-title">AI智能图书检索助手为您找到以下{{ pageData.inputValue }}的书,馆藏资源如下:</p>
              <div v-for="(citem, cindex) in getDisplayedBooks(item)" :key="cindex">
                <div class="message-text-header">
                  <div class="header-img">
                    <img src="../assets/images/book-mr.jpg" alt="" />
                  </div>
                  <ul class="header-main">
                    <li class="main-name">《{{ citem.name }}》</li>
                    <li class="header-main-flex">
                      <p>
                        <span class="main-title">责任者</span><span class="main-title-colon">:</span><span
                          class="main-content">{{
                            citem.author }}</span>
                      </p>
                      <p>
                        <span class="main-title">出版社</span><span class="main-title-colon">:</span><span
                          class="main-content">{{
                            citem.publisher
                          }}</span>
                      </p>
                    </li>
                    <li class="header-main-flex">
                      <p>
                        <span class="main-title">ISBN号</span><span class="main-title-colon">:</span><span
                          class="main-content">{{ citem.isbn
                          }}</span>
                      </p>
                      <p>
                        <span class="main-title">主题词</span><span class="main-title-colon">:</span><span
                          class="main-content">{{ citem.subject
                          }}</span>
                      </p>
                    </li>
                  </ul>
                </div>
                <div class="message-text-main">
                  <p class="text-main-title">
                    图书简介:</p>
                  <p class="text-main-main">{{ citem.brief }}</p>
                </div>
                <div class="message-text-footer" v-if="
                  citem.books && citem.books.length > 0
                " :class="{ 'no-border': cindex == getDisplayedBooks(item).length - 1 }">
                  <p class="text-footer-title">
                    <img src='../assets/images/table-title-bj.jpg' alt="">
                    <span>馆藏信息:</span>
                  </p>
                  <div class="text-footer-table">
                    <table cellpadding="10">
                      <tr class="table-header">
                        <th>序号</th>
                        <th>索书号</th>
                        <th>条形码</th>
                        <th>馆藏地</th>
                        <th>入档时间</th>
                        <th>书刊状态</th>
                      </tr>
                      <tr v-for="(ditem, dindex) in citem.books" :key="dindex">
                        <td>
                          {{ dindex + 1 }}
                        </td>
                        <td>
                          {{ ditem.indexNum }}
                        </td>
                        <td>{{ ditem.barcode }}</td>
                        <td>{{ ditem.libLoc }}</td>
                        <td>{{ ditem.filingDate }}</td>
                        <td>{{ ditem.collectionStatus }}</td>
                      </tr>
                    </table>
                  </div>
                </div>
              </div>
              <p class="message-text-titleOne">以上内容由AI生成,仅供参考。</p>
              <div class="message-text-change" @click="switchBooks(item)" v-if="!item.isEnd">
                <img src="../assets/images/shuxin1.png" alt="" />
                <span>换一换</span>
              </div>
              <div class="message-text-changeOne" v-else>
                <span>数据完结</span>
              </div>
            </div>
            <div class="select-item">
              <img src="../assets/images/lianwang.png" alt="" />
              <span>联网搜索</span>
            <!-- AI 文本消息 -->
            <div :class="['Ai-message-text', 'requestText' + index].join(' ')"
              v-if="item.type != 'user' && item.txtType == 'txt'">
              <div v-html="item.content"></div>
            </div>
            <!-- 消息底部时间 -->
            <div class="message-footer" v-if="item.type != 'user'">
              <span class="message-time">{{ item.time }}</span>
            </div>
          </div>
          <div class="select-right">
            <div class="select-item">
              <img src="../assets/images/fujian1.png" alt="" />
            </div>
            <div class="select-item">
              <img @click="sendMsg()" src="../assets/images/shangchuan2.png" alt="" />
        </div>
        <!-- 加载中状态 -->
        <div v-if="loading && index == message.length - 1" class="message assistant-message loading-message">
          <el-avatar class="assistant-avatar" :size="screenWidth > 375 ? 60 : 30" :src="assistantAvatar" />
          <div :class="['message-content', item.type === 'user' ? 'user-message-content' : '']">
            <div class="message-text-loading">
              <span class="dot-loading">思考中...</span>
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- 聊天底部输入区域 -->
    <div class="chat-footer">
      <!-- 输入框 -->
      <div class="chat-text">
        <el-input type="textarea" :autosize="{ minRows: 3, maxRows: 3 }" placeholder="请输入您的问题" v-model="inputValue"
          @keyup.enter.native="handleEnter($event)" />
        <!-- 发送按钮 -->
        <div class="select-item">
          <img @click="sendMsg()" src="../assets/images/shangchuan2.png" alt="" />
        </div>
      </div>
      <!-- 功能选择区域 -->
      <div class="select">
        <div class="select-right"></div>
      </div>
    </div>
  </div>
</template>
<script lang="ts" setup>
  import { ref } from 'vue'
  const inputValue = ref('')
import { reactive, nextTick, onMounted, ref, watch, computed } from 'vue'
import type { Start } from '@/types/start'
import router from '@/router/index'
import request from '@/plugin/axios/index' // 引入axios
import defaultImg from '../assets/images/image2.png'
import userIcon from '../assets/images/userIcon.jpg'
import dayjs from 'dayjs'
const inputValue = ref('')
const message = ref<any>([])
const loading = ref(false)
const autoScroll = ref(true)
const messagesContainer = ref<HTMLElement | null>(null)
const assistantAvatar = defaultImg
const userProfilePicture = userIcon
const screenWidth = ref(window.innerWidth)
const pageData = reactive<Start>({
  inputValue: "",
  questionList: [
    {
      question: "第一次来图书馆怎么借书回家看",
    },
    {
      question: "每次都是带孩子看看少儿书籍,其他书籍在哪看呢?",
    },
    {
      question: "我该怎么找我想要的书?",
    },
    {
      question: "书籍怎么检索?",
    },
    {
      question: "三楼和四楼的图书有什么不一样?",
    },
  ]
})
  const sendMsg = () => {
//返回首页
const handleBackClick = () => {
  router.push('/')
}
const scrollToBottom = async () => {
  if (!autoScroll.value) return
  await nextTick()
  if (messagesContainer.value) {
    const dom1 = document.querySelector('.dot-loading')
    const dom = document.querySelector('.requestText' + (message.value.length - 1))
    dom1?.scrollIntoView({ behavior: 'smooth', block: 'center' })
    dom?.scrollIntoView({ behavior: 'smooth', block: 'start' })
  }
//   import { ref } from 'vue'
// import { useRouter } from 'vue-router'
}
// const router = useRouter()
// const inputValue = ref('')
interface ChatMessage {
  content: string
  type: 'user' | 'assistant'
  time: string
  txtType: 'txt' | 'List'
  currentContentIndex: 0
  isEnd: boolean
}
// const handleChat = () => {
//   router.push('/chat')
// 换一换
const shuffleQuestions = () => {
  for (let i = pageData.questionList.length - 1; i > 0; i--) {
    const j = Math.floor(Math.random() * (i + 1));
    [pageData.questionList[i], pageData.questionList[j]] = [pageData.questionList[j], pageData.questionList[i]];
  }
};
//热门问题
const handleQuestionClick = (question: string) => {
  inputValue.value = question
  sendMsg()
}
const handleEnter = (event: any) => {
  event.preventDefault();
  inputValue.value = inputValue.value.replace(/\n/g, "")
  // 调用发送消息的方法
  sendMsg();
}
// 发送消息
const sendMsg = async () => {
  if (!inputValue.value.trim() || loading.value) return
  const userMessage: ChatMessage = {
    content: inputValue.value,
    type: 'user',
    time: new Date().toLocaleTimeString(),
    txtType: 'txt',
    currentContentIndex: 0,
    isEnd: false,
  }
  message.value.push(userMessage)
  const messageToSend = inputValue.value
  inputValue.value = ''
  try {
    await getData(messageToSend) // 使用 await 等待 getData 完成
  } catch (error) {
    console.error('发送消息失败', error)
  }
}
// 获取热门问题
const getCommonQyestuion = async () => {
  try {
    const response = await request({
      url: '/chat-messages',
      method: 'post',
      data: {
        inputs: {},
        query: "常见问题列表",
        parent_message_id: null,
        response_mode: 'blocking',
        conversation_id: '',
        user: 'abc-123',
        files: [],
      },
    })
    const answerAgain = JSON.parse((response as any).answer)
    const answerAgains = Object.keys(answerAgain.data);
    pageData.questionList = answerAgains.map((item: any) => {
      return {
        question: item
      }
    })
    // pageData.questionList = response.data
  } catch (error) {
    console.error('获取热门问题失败', error)
  }
}
// 再次回答
// const answerAgain = async (index: number) => {
//   let messageToSend = ""
//   for (let i = index - 1; i >= 0; i--) {
//     if (message.value[i].type == 'user') {
//       messageToSend = message.value[i].content;
//       break;
//     }
//   }
//   // 如果找到了用户消息内容,则调用 getData 方法
//   if (messageToSend) {
//     try {
//       console.log(messageToSend, "messageToSend");
//       await getData(messageToSend); // 使用 await 等待 getData 完成
//     } catch (error) {
//       console.error('发送消息失败', error);
//     }
//   } else {
//     console.error('未找到用户消息内容');
//   }
// }
// 获取数据
const getData = async (messageToSend: any) => {
  loading.value = true
  try {
    const response = await request({
      url: '/chat-messages',
      method: 'post',
      data: {
        inputs: {},
        query: messageToSend,
        parent_message_id: null,
        response_mode: 'blocking',
        conversation_id: '',
        user: 'abc-123',
        files: [],
      },
    })
    // response.answer = response.answer.replace(/\n/g, "<br>")
    const answerAgain = JSON.parse((response as any).answer)
    answerAgain.msg = answerAgain.msg.replace(/\n/g, "<br>")
    if (answerAgain.code == 1) {
      const assistantMessage: ChatMessage = {
        content: answerAgain.data,
        type: 'assistant',
        time: new Date().toLocaleTimeString(),
        txtType: 'List',
        currentContentIndex: 0,
        isEnd: false,
      }
      message.value.push(assistantMessage)
    } else if (answerAgain.code == 2 || answerAgain.code == 3) {
      const assistantMessage: ChatMessage = {
        content: answerAgain.msg,
        type: 'assistant',
        time: new Date().toLocaleTimeString(),
        txtType: 'txt',
        currentContentIndex: 0,
        isEnd: false,
      }
      message.value.push(assistantMessage)
    }
    loading.value = false
    // 保存消息到本地存储
    localStorage.setItem('chatMessages', JSON.stringify(message.value))
  } catch (error) {
    const assistantMessage: ChatMessage = {
      content: "当前操作遇到一些问题,请稍后再试。",
      type: 'assistant',
      time: new Date().toLocaleTimeString(),
      txtType: 'txt',
      currentContentIndex: 0,
      isEnd: false,
    }
    message.value.push(assistantMessage)
    console.error('发送消息失败', error)
  } finally {
    loading.value = false
  }
}
// 监听消息变化,自动滚动
watch(message.value, () => {
  scrollToBottom()
})
// 定义一个响应式的时间变量
const currentTime = ref(dayjs(new Date()).format('MM/DD HH:mm:ss'))
// 只返回前五个元素
const limitedQuestionList = computed(() => {
  return pageData.questionList.slice(0, 5);
});
const booksPerPage = 3;
// 计算当前应该显示的书籍集合
const getDisplayedBooks = (item: any) => {
  const start = item.currentContentIndex;
  return item.content.slice(start, start + booksPerPage);
};
// “换一换”按钮点击事件处理方法
const switchBooks = (item: any) => {
  const remainingItems = item.content.length - item.currentContentIndex - 3;
  // 检查剩余的数据量是否足够显示下一页
  if (remainingItems > booksPerPage) {
    // 如果足够,移动到下一组数据
    item.currentContentIndex += booksPerPage;
  } else if (remainingItems > 0 && remainingItems <= booksPerPage) {
    // 如果不足一整页但还有剩余数据,显示剩余的所有数据
    item.currentContentIndex += remainingItems;
    item.isEnd = true;
  }
};
// 从本地存储加载消息
onMounted(() => {
  getCommonQyestuion()
  // 删除本地缓存
  localStorage.removeItem('chatMessages');
  const savedMessages = localStorage.getItem('chatMessages')
  if (savedMessages) {
    message.value = JSON.parse(savedMessages)
  }
  scrollToBottom()
  screenWidth.value = window.innerWidth
})
</script>
<style lang="less" scoped>
  @media screen and (max-width: 750px) {
    .chat-box {
      width: 100%;
      height: auto;
      background-image: url('@/assets/images/beijing2.png');
      background-position: center;
      background-size: cover;
@media screen and (max-width: 750px) {
  .chat-box {
    width: 100%;
    height: 100%;
    background-image: url('@/assets/images/beijing2.png');
    background-position: center;
    background-size: cover;
    padding-top: 40px;
    position: relative;
      .chat-box-content {
        width: 100%;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        .chat-date {
          width: 100%;
          text-align: center;
          margin-bottom: 30px;
        }
        .chat-send {
          width: 100%;
          display: flex;
          justify-content: flex-end;
          margin-bottom: 20px;
          .chat-send-info {
            width: 263px;
            height: 40px;
            background: #af8b56;
            border-radius: 20px;
            line-height: 40px;
            padding: 0 20px;
            color: #fff;
          }
        }
        .chat-back-info {
          margin-bottom: 20px;
          display: flex;
          justify-content: flex-start;
          .back-avator {
            margin-right: 10px;
            img {
              width: 40px;
            }
          }
          .base-book-box {
            width: 300px;
            padding: 20px;
            box-sizing: border-box;
            background-color: #fff;
            border-radius: 20px;
          }
        }
        .back-item {
          width: 300px;
          background: #ffffff;
          border-radius: 20px;
          margin-left: 50px;
          margin-bottom: 20px;
          .back-item-title {
            width: 80%;
            height: 60px;
            display: flex;
            align-items: center;
            padding: 0 10px;
            margin: auto;
            border-bottom: 1px solid #e9d8bf;
          }
          img {
            margin-right: 10px;
          }
          ul {
            padding: 0 25px;
            li {
              list-style: none;
              margin: 10px 0 10px 0;
              display: flex;
              justify-content: flex-start;
              align-items: center;
            }
          }
          .chat-change {
            display: flex;
            justify-content: flex-end;
            align-items: center;
            padding: 10px 20px;
            color: #d2a25b;
            img {
              cursor: pointer;
            }
          }
        }
        .chat-footer {
          width: 300px;
          background-color: #fff;
          border-radius: 20px;
          padding: 20px;
          box-sizing: border-box;
          margin-left: 50px;
          margin-bottom: 20px;
          .icon-list img {
            margin-right: 10px;
            cursor: pointer;
          }
          ::v-deep(.chat-text) {
            margin-bottom: 10px;
            .el-textarea__inner {
              border: none !important;
              outline: none !important;
              box-shadow: none !important;
              background-color: transparent !important;
              resize: none !important;
            }
          }
          .select {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: space-between;
            .select-left,
            .select-right {
              display: flex;
              align-items: center;
              justify-content: flex-start;
              .select-item {
                display: flex;
                align-items: center;
                box-sizing: border-box;
                border: 1px solid #e9d8bf;
                border-radius: 15px;
                font-size: 12px;
                font-family:
                  Microsoft YaHei,
                  Microsoft YaHei-Regular;
                font-weight: 400;
                color: #e1c49a;
                img {
                  margin-right: 5px;
                  cursor: pointer;
                }
              }
            }
            .select-left {
              .select-item {
                min-width: 70px;
                padding: 5px 8px;
              }
            }
            .select-right {
              display: flex;
              align-items: center;
              justify-content: flex-end;
              .select-item {
                border: 0;
              }
            }
          }
        }
    .chat-back-icon {
      position: absolute;
      top: 10px;
      left: 10px;
      text-align: left;
      display: flex;
      el-icon{
        cursor: pointer;
      }
    }
  }
  @media screen and (min-width: 750px) {
    .chat-box {
    .chat-box-content {
      width: 100%;
      height: 100%;
      background-image: url('@/assets/images/beijing2.png');
      background-size: 100% 100%;
      background-position: center;
      background-repeat: no-repeat;
      height: calc(100vh - 153px);
      display: flex;
      justify-content: center;
      align-items: center;
      flex-direction: column;
      overflow: auto;
      justify-content: flex-start;
      align-items: flex-start;
      .chat-box-content {
        width: 1200px;
      .chat-date {
        color: #999;
        width: 100%;
        text-align: center;
        margin-bottom: 10px;
        margin-top: 10px;
      }
      .chat-send {
        width: 100%;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        align-items: flex-start;
        justify-content: flex-end;
        margin-bottom: 20px;
        .chat-date {
          width: 100%;
          text-align: center;
          margin-bottom: 30px;
        }
        .chat-send {
          width: 100%;
          display: flex;
          justify-content: flex-end;
          margin-bottom: 20px;
          .chat-send-info {
            width: 263px;
            height: 40px;
            background: #af8b56;
            border-radius: 20px;
            line-height: 40px;
            padding: 0 20px;
            color: #fff;
          }
        }
        .chat-back-info {
          margin-bottom: 20px;
          display: flex;
          justify-content: flex-start;
          .back-avator {
            margin-right: 37px;
            img {
              width: 60px;
            }
          }
          .base-book-box {
            width: 800px;
            padding: 20px 47px;
            box-sizing: border-box;
            background-color: #fff;
            border-radius: 20px;
          }
        }
        .back-item {
          width: 349px;
          height: 391px;
          background: #ffffff;
        .chat-send-info {
          width: 263px;
          height: 40px;
          background: #af8b56;
          border-radius: 20px;
          margin-left: 100px;
          margin-bottom: 20px;
          line-height: 40px;
          padding: 0 20px;
          color: #fff;
        }
      }
          .back-item-title {
            width: 80%;
            height: 60px;
            display: flex;
            align-items: center;
            padding: 0 10px;
            margin: auto;
            border-bottom: 1px solid #e9d8bf;
          }
      .chat-back-info {
        margin-bottom: 20px;
        display: flex;
        justify-content: flex-start;
        min-height: 92px;
        .back-avator {
          margin-right: 10px;
          img {
            margin-right: 10px;
            width: 40px;
          }
        }
          ul li {
        .base-book-box {
          display: inline-block;
          width: 80%;
          padding: 15px;
          box-sizing: border-box;
          background-color: #fff;
          border-radius: 20px;
          font-size: 14px;
        }
      }
      .back-item {
        max-width: 80%;
        background: #ffffff;
        border-radius: 20px;
        margin-left: 50px;
        margin-bottom: 20px;
        font-size: 14px;
        .back-item-title {
          width: 80%;
          height: 60px;
          display: flex;
          align-items: center;
          padding: 0 10px;
          margin: auto;
          border-bottom: 1px solid #e9d8bf;
        }
        .hot-question {
          cursor: pointer;
          &:hover {
            color: #d2a25b;
          }
        }
        img {
          margin-right: 10px;
        }
        ul {
          padding: 0 25px;
          li {
            list-style: none;
            margin: 20px 0 20px 0;
            margin: 10px 0 10px 0;
            display: flex;
            justify-content: flex-start;
            align-items: center;
          }
        }
          .chat-change {
        .chat-change {
          display: flex;
          justify-content: flex-end;
          align-items: center;
          padding: 10px 20px;
          color: #d2a25b;
          cursor: pointer;
          img {
            cursor: pointer;
          }
        }
      }
      .chat-box-content-item {
        width: 100%;
      }
    }
    .chat-footer {
      width: 90%;
      margin: auto;
      background-color: #fff;
      border-radius: 20px;
      padding: 10px;
      box-sizing: border-box;
      margin-bottom: 20px;
      .icon-list img {
        margin-right: 10px;
        cursor: pointer;
      }
      ::v-deep(.chat-text) {
        margin-bottom: 10px;
        height: 100%;
        display: flex;
        align-items: center;
        .el-textarea__inner {
          border: none !important;
          outline: none !important;
          box-shadow: none !important;
          background-color: transparent !important;
          resize: none !important;
        }
      }
      .select {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        .select-left,
        .select-right {
          display: flex;
          align-items: center;
          justify-content: flex-start;
          .select-item {
            display: flex;
            justify-content: flex-end;
            align-items: center;
            padding: 0 20px;
            color: #d2a25b;
            box-sizing: border-box;
            border: 1px solid #e9d8bf;
            border-radius: 15px;
            font-size: 12px;
            font-family:
              Microsoft YaHei,
              Microsoft YaHei-Regular;
            font-weight: 400;
            color: #e1c49a;
            img {
              height: auto;
              margin-right: 5px;
              cursor: pointer;
            }
          }
        }
        .chat-footer {
          width: 800px;
          height: 170px;
          background-color: #fff;
          border-radius: 20px;
          padding: 20px;
          box-sizing: border-box;
          margin-left: 103px;
          .icon-list img {
            margin-right: 10px;
            cursor: pointer;
        .select-left {
          .select-item {
            min-width: 70px;
            padding: 5px 8px;
            margin-left: 2px;
          }
        }
          ::v-deep(.chat-text) {
            margin-bottom: 10px;
        .select-right {
          display: flex;
          align-items: center;
          justify-content: flex-end;
            .el-textarea__inner {
              border: none !important;
              outline: none !important;
              box-shadow: none !important;
              background-color: transparent !important;
              resize: none !important;
            }
          }
          .select {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: space-between;
            .select-left,
            .select-right {
              flex: 1;
              display: flex;
              align-items: center;
              justify-content: flex-start;
              .select-item {
                display: flex;
                align-items: center;
                padding: 2px 10px;
                box-sizing: border-box;
                border: 1px solid #e9d8bf;
                border-radius: 15px;
                margin-right: 10px;
                font-size: 14px;
                font-family:
                  Microsoft YaHei,
                  Microsoft YaHei-Regular;
                font-weight: 400;
                color: #e1c49a;
                img {
                  margin-right: 10px;
                  cursor: pointer;
                }
              }
            }
            .select-right {
              display: flex;
              align-items: center;
              justify-content: flex-end;
              .select-item {
                border: 0;
              }
            }
          .select-item {
            border: 0;
            margin-left: 2px;
          }
        }
      }
    }
    .message {
      width: 100%;
      display: flex;
      margin-bottom: 24px;
      align-items: flex-start;
      animation: slideIn 0.3s ease;
      animation-fill-mode: forwards;
      max-width: 90%;
      border-radius: 12px;
      // box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
      padding: 16px;
      padding-left: 3px;
    }
    .assistant-avatar {
      min-width: 40px;
      max-width: 40px;
      height: auto;
    }
    .message-content {
      display: inline-block;
      max-width: 80%;
      background: #fff;
      margin-left: 10px;
      border-radius: 20px;
      padding: 3px 10px;
      margin-top: 5px;
      margin-right: 10px;
    }
    .user-message-text {
      color: #fff;
    }
    .message-text {
      width: 100%;
      padding: 6px 8px;
      border-radius: 12px;
      word-wrap: break-word;
      line-height: 1.6;
      font-size: 0.95rem;
      transition: all 0.3s ease;
      white-space: pre-wrap;
      color: #333;
      .message-text-title {
        font-size: 14px;
        color: #999;
        line-height: 20px;
        padding: 10px 0 20px 0;
      }
      .message-text-header {
        ul {
          list-style-type: none;
        }
        li {
          list-style-type: none;
        }
        .header-img {
          display: flex;
          justify-content: center;
          img {
            width: 65%;
          }
        }
        .header-main {
          padding: 10px 0;
          .main-name {
            width: 100%;
            font-size: 18px;
            font-family: Microsoft YaHei, Microsoft YaHei-Bold;
            font-weight: 700;
            text-align: center;
            color: #333333;
            margin-bottom: 20px
          }
          .header-main-flex {
            padding: 0 10px;
            .main-title {
              font-size: 14px;
              display: inline-block;
              width: 28.5%;
              text-wrap: nowrap;
              color: #000;
              text-align: justify;
              letter-spacing: 0.1em;
              /* 调整字母间距 */
              text-align-last: justify;
              /* 确保最后一行文本也均匀分布 */
              display: inline-block;
              /* 设置为行内块元素 */
              vertical-align: top;
              /* 顶部对齐 */
            }
            .main-title-colon {
              color: #000;
              margin-right: 3px;
              margin-left: 1px;
              display: inline-block;
              /* 设置为行内块元素 */
              vertical-align: top;
              /* 顶部对齐 */
            }
            .main-content {
              font-size: 14px;
              display: inline-block;
              /* 设置为行内块元素 */
              /* 顶部对齐 */
              max-width: calc(72.5% - 15px);
              /* 减去.main-title宽度和.main-title-colon的margin-right */
              word-wrap: break-word;
              /* 允许在长单词或无空格字符串内部进行换行 */
            }
            p {
              width: 100%;
              overflow: hidden;
              font-size: 14px;
              margin: 2px 0;
              color: #a5a5a5;
            }
            span {
              font-size: 14px;
            }
          }
        }
      }
      .message-text-main {
        padding: 10px 0;
        .text-main-title {
          font-size: 15px;
          font-weight: bold;
          color: #a88868;
          margin: 3px 0;
        }
        .text-main-main {
          margin-top: 5px;
          max-height: 150px;
          min-height: 150px;
          overflow: auto;
          font-size: 14px;
          line-height: 26px;
          text-align: justify;
          color: #6d6d6d;
        }
      }
      .no-border {
        border-bottom: none !important;
      }
      .message-text-footer {
        width: 100%;
        margin-top: 10px;
        margin-bottom: 10px;
        padding-bottom: 20px;
        border-bottom: 1px solid #e9d8bf;
        .text-main-footer {
          width: 100%;
        }
        .text-footer-title {
          position: relative;
          img {
            max-width: 50%;
            margin-bottom: 10px;
          }
          span {
            font-size: 15px;
            font-weight: bold;
            color: #fff;
            position: absolute;
            left: 2%;
            top: 3.5%;
          }
        }
        .text-footer-table {
          width: 100%;
          overflow-x: auto;
        }
        table {
          width: 100%;
          border-collapse: collapse;
        }
        th {
          text-wrap: nowrap;
          background-color: #f9ecd8;
          color: #b3b3b3 !important;
        }
        tr {
          width: 5%;
        }
        td {
          text-wrap: nowrap;
          text-align: center;
        }
        tr:nth-child(odd) {
          background-color: #f9ecd8;
          /* 奇数行背景颜色 */
        }
        tr:nth-child(even) {
          background-color: #fff7eb;
          /* 偶数行背景颜色 */
        }
      }
      .message-text-titleOne {
        text-align: right;
        color: #fe7313;
        font-size: 10px;
        padding-bottom: 5px;
        border-bottom: 1px solid #e9d8bf;
      }
      .message-text-change {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        padding: 10px 0 0 0;
        cursor: pointer;
        img {
          margin-right: 10px;
        }
        span {
          font-size: 14px;
          font-family: Microsoft YaHei, Microsoft YaHei-Regular;
          font-weight: 400;
          text-align: left;
          color: #d2a25b;
          line-height: 35px;
        }
      }
      .message-text-changeOne {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        padding: 10px 0 0 0;
        span {
          font-size: 14px;
          font-family: Microsoft YaHei, Microsoft YaHei-Regular;
          font-weight: 400;
          text-align: left;
          color: #d2a25b;
          line-height: 35px;
        }
      }
    }
    .message-text-loading {
      padding: 0px 10px;
      border-radius: 10px;
      word-wrap: break-word;
      line-height: 1.6;
      font-size: 0.95rem;
      transition: all 0.3s ease;
      white-space: pre-wrap;
      color: #333;
    }
    .Ai-message-text {
      div {
        font-size: 16px;
        text-indent: 1em;
      }
    }
    .user-message {
      flex-direction: row-reverse;
      margin-left: auto;
    }
    .user-message .message-text {
      color: #8b6e47;
    }
    .message-footer {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-top: 8px;
      padding: 0 4px;
      color: #999;
    }
    .message-time {
      font-size: 0.70rem;
      color: #999;
      margin-left: 10px;
    }
  }
</style>
}
@media screen and (min-width: 750px) {
  .chat-box {
    width: 100%;
    height: 100%;
    background-image: url('@/assets/images/beijing2.png');
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding-bottom: 10px;
    position: relative;
    .chat-back-icon {
      position: absolute;
      top: 30px;
      width: 80%;
      text-align: left;
      display: flex;
      el-icon{
        cursor: pointer;
      }
    }
    .chat-box-content {
      width: 1200px;
      min-width: 1200px;
      height: calc(100vh - 100px);
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
      overflow: auto;
      align-items: flex-start;
      .chat-send {
        width: 100%;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: flex-end;
        margin-bottom: 20px;
        .chat-send-info {
          width: 263px;
          height: 40px;
          background: #af8b56;
          border-radius: 20px;
          line-height: 40px;
          padding: 0 20px;
          color: #fff;
        }
        .chat-message {
          width: 263px;
          height: 40px;
          background: #fff;
          border-radius: 20px;
          line-height: 40px;
          padding: 0 20px;
          color: #000;
        }
      }
      .chat-date {
        color: #999;
        width: 100%;
        text-align: center;
        margin-bottom: 30px;
        margin-top: 30px;
      }
      .chat-send {
        width: 100%;
        display: flex;
        justify-content: flex-end;
        margin-bottom: 20px;
        .chat-send-info {
          width: 263px;
          height: 40px;
          background: #af8b56;
          border-radius: 20px;
          line-height: 40px;
          padding: 0 20px;
          color: #fff;
        }
      }
      .chat-back-info {
        margin-bottom: 20px;
        display: flex;
        justify-content: flex-start;
        min-height: 90px;
        .back-avator {
          margin-right: 37px;
          img {
            width: 60px;
          }
        }
        .base-book-box {
          display: flex;
          width: 800px;
          padding: 20px 47px;
          box-sizing: border-box;
          background-color: #fff;
          border-radius: 20px;
        }
      }
      .back-item {
        width: 349px;
        height: auto;
        background: #ffffff;
        border-radius: 20px;
        margin-left: 100px;
        margin-bottom: 20px;
        .back-item-title {
          width: 80%;
          height: 60px;
          display: flex;
          align-items: center;
          padding: 0 10px;
          margin: auto;
          border-bottom: 1px solid #e9d8bf;
        }
        .hot-question {
          cursor: pointer;
          &:hover {
            color: #d2a25b;
          }
        }
        img {
          margin-right: 10px;
        }
        ul li {
          list-style: none;
          margin: 20px 0 20px 0;
          display: flex;
          justify-content: flex-start;
          align-items: center;
        }
        .chat-change {
          display: flex;
          justify-content: flex-end;
          align-items: center;
          padding: 0 20px;
          color: #d2a25b;
          margin-bottom: 10px;
          cursor: pointer;
          img {
            cursor: pointer;
          }
        }
      }
      .chat-box-content-item {
        width: 100%;
      }
    }
    .chat-box-content::-webkit-scrollbar {
      width: 1px;
    }
    /* 隐藏水平滚动条 */
    .chat-box-content::-webkit-scrollbar {
      height: 0;
    }
    .chat-footer {
      width: 1200px;
      height: 100px;
      background-color: #fff;
      border-radius: 20px;
      padding: 20px;
      box-sizing: border-box;
      .icon-list img {
        margin-right: 10px;
        cursor: pointer;
      }
      ::v-deep(.chat-text) {
        height: 100%;
        display: flex;
        align-items: center;
        margin-bottom: 10px;
        .el-textarea__inner {
          overflow: auto;
          height: 100% !important;
          border: none !important;
          outline: none !important;
          box-shadow: none !important;
          background-color: transparent !important;
          resize: none !important;
        }
        img {
          cursor: pointer;
          min-height: 25px;
        }
      }
      .select {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        .select-left,
        .select-right {
          flex: 1;
          display: flex;
          align-items: center;
          justify-content: flex-start;
          .select-item {
            display: flex;
            align-items: center;
            padding: 2px 10px;
            box-sizing: border-box;
            border: 1px solid #e9d8bf;
            border-radius: 15px;
            margin-right: 10px;
            font-size: 14px;
            font-family:
              Microsoft YaHei,
              Microsoft YaHei-Regular;
            font-weight: 400;
            color: #e1c49a;
            img {
              margin-right: 10px;
              cursor: pointer;
            }
          }
        }
        .select-right {
          display: flex;
          align-items: center;
          justify-content: flex-end;
          .select-item {
            border: 0;
          }
        }
      }
    }
    .message {
      display: flex;
      margin-bottom: 24px;
      align-items: flex-start;
      animation: slideIn 0.3s ease;
      animation-fill-mode: forwards;
      max-width: 85%;
      border-radius: 12px;
      // box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
      padding: 16px;
    }
    .assistant-avatar {
      min-width: 60px;
      max-width: 60px;
      height: auto;
    }
    .message-content {
      display: inline-block;
      margin-top: 10px;
      max-width: 85%;
      background: #fff;
      margin-left: 20px;
      margin-right: 20px;
      border-radius: 20px;
      padding: 10px 10px;
    }
    .user-message-text {
      // text-indent: 1em;
      color: #fff;
    }
    .message-text {
      min-width: 800px;
      padding: 0px 40px;
      border-radius: 12px;
      word-wrap: break-word;
      line-height: 1.6;
      font-size: 0.95rem;
      transition: all 0.3s ease;
      white-space: pre-wrap;
      color: #333;
      .message-text-title {
        font-size: 16px;
        color: #999;
        line-height: 35px;
        padding: 20px 0 30px 0;
      }
      .message-text-header {
        display: flex;
        ul {
          list-style-type: none;
        }
        li {
          list-style-type: none;
        }
        .header-img {
          width: 20%;
          margin-right: 20px;
          display: flex;
          align-items: center;
          img {
            width: 100%;
          }
        }
        .header-main {
          width: 80%;
          padding: 10px 0;
          .header-main-flex {
            display: flex;
            p {
              width: 50%;
              overflow: hidden;
              font-size: 16px;
              margin: 2px 0;
              color: #a5a5a5;
            }
          }
        }
        .main-name {
          font-size: 18px;
          margin-bottom: 10px;
        }
        .main-title {
          display: inline-block;
          width: 25%;
          text-wrap: nowrap;
          color: #000;
          text-align: justify;
          letter-spacing: 0.1em;
          /* 调整字母间距 */
          text-align-last: justify;
          /* 确保最后一行文本也均匀分布 */
          display: inline-block;
          /* 设置为行内块元素 */
          vertical-align: top;
          /* 顶部对齐 */
        }
        .main-title-colon {
          color: #000;
          margin-right: 5px;
          display: inline-block;
          /* 设置为行内块元素 */
          vertical-align: top;
          /* 顶部对齐 */
        }
        .main-content {
          font-size: 14px;
          display: inline-block;
          /* 设置为行内块元素 */
          vertical-align: top;
          /* 顶部对齐 */
          max-width: calc(75% - 15px);
          /* 减去.main-title宽度和.main-title-colon的margin-right */
          word-wrap: break-word;
          /* 允许在长单词或无空格字符串内部进行换行 */
        }
      }
      .message-text-main {
        padding: 10px 10px;
        .text-main-title {
          font-size: 16px;
          font-weight: bold;
          color: #a88868;
          margin: 5px 0;
        }
        .text-main-main {
          margin-top: 10px;
          max-height: 92px;
          min-height: 92px;
          overflow: auto;
          font-size: 14px;
          line-height: 26px;
          text-align: justify;
          color: #6d6d6d;
        }
      }
      .no-border {
        border-bottom: none !important;
      }
      .message-text-footer {
        margin-top: 30px;
        margin-bottom: 20px;
        padding-bottom: 30px;
        border-bottom: 1px solid #e9d8bf;
        .text-main-footer {
          width: 100%;
        }
        .text-footer-title {
          position: relative;
          img {
            max-width: 18%;
            margin-bottom: 20px;
          }
          span {
            font-size: 19px;
            font-weight: bold;
            color: #fff;
            position: absolute;
            left: 2%;
          }
        }
        table {
          width: 100%;
          border-collapse: collapse;
        }
        th {
          background-color: #f9ecd8;
          color: #b3b3b3 !important;
        }
        tr {
          width: 100%;
        }
        td {
          text-align: center;
        }
        tr:nth-child(odd) {
          background-color: #f9ecd8;
          /* 奇数行背景颜色 */
        }
        tr:nth-child(even) {
          background-color: #fff7eb;
          /* 偶数行背景颜色 */
        }
      }
      .message-text-titleOne {
        text-align: right;
        color: #fe7313;
        font-size: 10px;
        padding-bottom: 5px;
        border-bottom: 1px solid #e9d8bf;
      }
      .message-text-change {
        display: flex;
        align-items: center;
        padding: 10px 0 0 0;
        cursor: pointer;
        img {
          margin-right: 10px;
        }
        span {
          font-size: 14px;
          font-family: Microsoft YaHei, Microsoft YaHei-Regular;
          font-weight: 400;
          text-align: left;
          color: #d2a25b;
          line-height: 35px;
        }
      }
      .message-text-changeOne {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        padding: 10px 0 0 0;
        span {
          font-size: 14px;
          font-family: Microsoft YaHei, Microsoft YaHei-Regular;
          font-weight: 400;
          text-align: left;
          color: #d2a25b;
          line-height: 35px;
        }
      }
    }
    .message-text-loading {
      padding: 0px 10px;
      border-radius: 10px;
      word-wrap: break-word;
      line-height: 1.6;
      font-size: 0.95rem;
      transition: all 0.3s ease;
      white-space: pre-wrap;
      color: #333;
    }
    .Ai-message-text {
      div {
        font-size: 16px;
      }
    }
    .user-message {
      flex-direction: row-reverse;
      margin-left: auto;
    }
    .user-message .message-text {
      justify-content: center;
      color: #8b6e47;
    }
    .message-footer {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-top: 5px;
      padding: 0 4px;
      color: #999;
    }
    .message-time {
      font-size: 0.75rem;
      color: #999;
      margin-left: 10px;
    }
  }
}
.user-message-content {
  background: #af8b56 !important;
  .message-text {
    color: #fff !important;
    padding: 5px 10px;
  }
}
</style>