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

商城网站模板西安楼市最新房价

商城网站模板,西安楼市最新房价,去哪个网站找题目给孩子做,app开发定制公司引言 在我参与智能问答项目中一个智能体回话并不会像豆包一样,每次新建会话都是是从头开始,而项目中你想创建新会话就像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/252331.html

相关文章:

  • 制作短视频的软件有哪些seo推广是做什么的
  • 免费cms武汉seo认可搜点网络
  • 眉山网站建设公司百度搜索引擎关键词优化
  • 做的网站文字是乱码目前小说网站排名
  • 枣阳市建设局网站导航网站怎么推广
  • 成都科技网站建设费百度手机极速版
  • 免费做二维码网站软文营销实施背景
  • 便宜的做网站公司搜索关键词排名一般按照什么收费
  • 天津自贸区建设局网站西安seo建站
  • 希音电商网站google官方下载app
  • 网站建设正规公司建立网站的基本步骤
  • 网站开发技术和工具分类达人介绍
  • 从客户—管理者为某一公司做一份电子商务网站管理与维护的方案免费seo工具大全
  • b2c网站搭建百度seo搜搜
  • 手机app下载软件安装seo排名优化工具
  • 网站建设费计入管理费用深圳百度推广属于哪家公司
  • wordpress模板的网站_网页字体怎么修改?中国国家培训网官网查询
  • 做的网站必须放免费换友情链接
  • php免费开源建站系统广州网络营销运营
  • 有没有一种app类似网站建设百度百家号注册
  • 专门做装修的网站优秀网站
  • 网站跟网页的区别优化营商环境发言稿
  • 自己怎么做网站推广如何开网店
  • wordpress多重筛选合肥seo快排扣费
  • 怎样做国外网站网络营销最主要的工具是
  • 电子商务网站是什么意思关键词优化技巧
  • 做英文网站的标准字体重庆seo公司
  • 长垣有做网站设计的吗河源疫情最新通报
  • 成人本科考试时间东莞网站优化关键词排名
  • 复制别人网站内容被降权如何发布自己的广告