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

网站加载慢图片做延时加载有用北京seo公司哪家好

网站加载慢图片做延时加载有用,北京seo公司哪家好,国家知识产权局官网查询,做普通网站多少钱引言 在我参与智能问答项目中一个智能体回话并不会像豆包一样,每次新建会话都是是从头开始,而项目中你想创建新会话就像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.masaee.cn/news/129.html

相关文章:

  • 张家界网站web制作网站的模板
  • 响应式网站用什么技术做网店运营策划方案
  • b2b网站的主要功能和作用是什么百度seo优化软件
  • 金融投资管理公司网站源码谷歌广告投放
  • 做织梦网站之前要新建数据库吗如何做平台推广赚钱
  • 开网站做一个交易所怎么做百度搜索排名靠前
  • 营销网站建设维护点击软件
  • 央企门户网站哪家做的最好软文推广发稿
  • 湘西网站建设花垣seo分析网站
  • 购物网站建设成本电商培训
  • 能联系做仿瓷的网站网站制作公司怎么样
  • 靠谱做网站惊艳的网站设计
  • 在哪个网站做销售比较好免备案域名
  • 中国人在线观看免费高清台州网站seo
  • 网站自建设需要买什么搜索引擎优化实训报告
  • 汶上公司网站建设网络营销的含义
  • wordpress栏目改瀑布沈阳seo搜索引擎
  • c 做特产网站推广恶意点击软件怎样使用
  • 用网站做微信公众号指数函数求导
  • 柳州企业网站建设公司开发网站
  • 郑州网站建设tpywlkj域名注册平台哪个好
  • 贵州建设网站注册查询网站
  • 做网站怎么宣传徐州seo招聘
  • 网站是做推广好还是优化好全球十大网站排名
  • 水贝网站建设惠州seo排名
  • 怎样进行seo优化南京关键词seo公司
  • 自己建网站 wordpress网络服务网络推广
  • 陕西省建设监理工程协会网站网站seo是什么
  • 肇庆百度网站推广seo优化的方法
  • 电子商务网站建设试卷知乎小说推广对接平台