当前位置: 首页 > wzjs >正文

商城网站模板免费广告发布平台app

商城网站模板,免费广告发布平台app,wordpress导入数据库,谷城网站定制引言 在我参与智能问答项目中一个智能体回话并不会像豆包一样,每次新建会话都是是从头开始,而项目中你想创建新会话就像chatbox一样,是点击橡皮擦开启新的聊天上下文,但是直接的聊天记录依然存在,针对超过十万&#xf…

引言

在我参与智能问答项目中一个智能体回话并不会像豆包一样,每次新建会话都是是从头开始,而项目中你想创建新会话就像chatbox一样,是点击橡皮擦开启新的聊天上下文,但是直接的聊天记录依然存在,针对超过十万+条对话数据进行展示。会出现页面卡死的问题。
所以我们可以通过虚拟列表的形式展示我们的对话内容
在这里插入图片描述

<template><div class="container"><!-- 展示问答内容 --><div class="chat-container" ref="chatContainer" @scroll="handleScroll"><!-- 优化后 --><divclass="virtual-placeholder":style="{ height: `${chatListHeight}px` }"></div><divclass="truth-box":style="{ transform: `translateY(${scrollTop}px)` }"><divclass="chat-item-container":style="{ transform: `translateY(${scrollTopItem}px)` }"><divv-for="(item, index) in renderedItems":key="index"class="chat-item":style="{ height: `${item.height}px` }"><div v-if="item.isUser" class="user-message">{{ item.content }}</div><div v-else class="system-message">{{ item.content }}</div></div></div></div><!-- ------------------------------------------- --><!-- 优化前 --><!-- <divv-for="(item, index) in chatList":key="index"class="chat-item":style="{ height: `${item.height}px` }"><div v-if="item.isUser" class="user-message">{{ item.content }}</div><div v-else class="system-message">{{ item.content }}</div></div> --></div><!-- 输入框与发送按钮 --><el-row type="flex" justify="center"><el-col :span="18"><el-input v-model="inputValue" placeholder="请输入内容"></el-input></el-col><el-col :span="6"><el-button type="primary" @click="send">发送</el-button></el-col></el-row></div>
</template><script>
export default {data() {return {inputValue: '',chatList: [],startIndex: 0,visibleCount: 20, // 可视区域内显示的条目数itemHeight: 100, // 假设每个条目平均高度为 100pxscrollTop: 0,}},computed: {chatListLength() {return this.chatList.length},chatListHeight() {return ((this.chatList.reduce((acc, item) => acc + item.height, 0) *this.chatListLength) /this.chatListLength)},renderedItems() {console.log('renderedItems', this.startIndex)return this.chatList.slice(this.startIndex,this.startIndex + this.visibleCount)},startOffset() {return this.chatList.slice(0, this.startIndex).reduce((acc, item) => acc + item.height, 0)},scrollTopItem() {return this.startOffset - this.scrollTop},},mounted() {this.chatList = new Array(100000).fill(0).map(() => {return {isUser: Math.random() > 0.5,content: '欢迎来到我们的帮助中心!',height: Math.random() * 100 + 50,}})},methods: {send() {if (this.inputValue.trim() !== '') {// 添加用户的输入到聊天列表this.chatList.push({isUser: true,content: this.inputValue,height: Math.random() * 100 + 50,})// 模拟系统回复setTimeout(() => {this.chatList.push({isUser: false,content: '你可以通过点击设置选项来修改账户信息。',height: Math.random() * 100 + 50,})}, 500)// 清空输入框this.inputValue = ''// 自动滚动到底部this.scrollToBottom()}},handleScroll() {const scrollTop = this.$refs.chatContainer.scrollTopthis.scrollTop = scrollToplet currentStartIndex = 0let totalHeiight = 0for (let i = 0; i < this.chatList.length; i++) {const item = this.chatList[i]totalHeiight += item.heightif (totalHeiight >= scrollTop) {currentStartIndex = ibreak}}this.startIndex = currentStartIndex >= 0 ? currentStartIndex : 0},scrollToBottom() {this.$nextTick(() => {const container = this.$refs.chatContainer// 正确设置滚动到底部container.scrollTop = container.scrollHeight})},},
}
</script>
<style lang="scss" scoped>
.container {display: flex;flex-direction: column;height: 100%;
}
.chat-container {flex: 1;height: 0;overflow-y: auto;position: relative;.truth-box {width: 100%;position: absolute;top: 0;left: 0;overflow: hidden;height: 100%;}
}
.chat-item-container {position: absolute;top: 0;left: 0;width: 100%;
}
.chat-item {
}.user-message {text-align: right;color: #409eff; // Element UI 蓝色background: pink;height: 100%;
}.system-message {height: 100%;text-align: left;color: #67c23a; // Element UI 绿色background: gray;
}
</style>
http://www.dtcms.com/wzjs/158964.html

相关文章:

  • 做网站 用哪个网盘好关键词网络推广企业
  • 上海市电话黄页本东莞百度seo电话
  • 网站左侧导航代码化工网站关键词优化
  • 嘉定网站设计制作报价以图搜图百度识图网页版
  • 长春优惠做网站关键词优化公司哪家好
  • 怎么查网站注册时间百度seo推广
  • 上海建设部网站首页现在最火的发帖平台
  • 南平 建网站网站建设平台
  • wordpress 插件api廊坊seo推广公司
  • 专做婚宴用酒是网站企业员工培训课程有哪些
  • 清远建设局网站百度上怎么免费开店
  • 自助建网站推广网站大全
  • 求html码源网站站长工具域名查询社区
  • 网站服务器迁移网络工程师是干什么的
  • 网站图片展示方式有哪些怎样交换友情链接
  • 医学关键词 是哪个网站做网络营销的现状分析
  • 毕业论文网站建设模板电话营销
  • 贵州网站建设seo优化网站推广的基本方法有
  • 大连做网站seo新方法
  • 网站文章收录查询湖北网站建设制作
  • 做网站推广多少钱石家庄seo关键词
  • 高安高端网站设计公司优化设计五年级下册语文答案
  • 怎样做网站域名注册seo软文推广工具
  • 网站的站点建设分为seo点石论坛
  • 股权众筹网站开发关键词优化seo外包
  • 福州哪里制作网站广告设计需要学什么
  • 如何做seo网站网页设计培训学校
  • 自己建的网站如何百度搜索seo技术优化服务
  • 网站的用户运营值得做吗简述网站内容如何优化
  • 怎么样做自己的网站新产品推广方案范文