提交 1e78ce8c 作者: 毛细亚

优化AI聊天组件样式与交互逻辑

上级 59494996
...@@ -10,14 +10,14 @@ ...@@ -10,14 +10,14 @@
<p v-for="(name, index) in knowledge_search_list" style="margin-bottom:10px;" <p v-for="(name, index) in knowledge_search_list" style="margin-bottom:10px;"
:key="index"> :key="index">
<el-tag size="mini">{{ name <el-tag size="mini">{{ name
}}</el-tag> }}</el-tag>
</p> </p>
</div> </div>
<el-button type="text" size="medium" slot="reference">{{ knowledge_search_list.length <el-button type="text" size="medium" slot="reference">{{ knowledge_search_list.length
}}</el-button> }}</el-button>
</el-popover> </el-popover>
</p> </p>
<el-button type="text" @click="clearContext" class="clearContext">清除上下文</el-button> <el-button type="text" @click="clearContextComfion" class="clearContext">清除上下文</el-button>
</div> </div>
</div> </div>
</div> </div>
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
<!-- v-loadingChat="loading" --> <!-- v-loadingChat="loading" -->
<div ref="ai-box" v-debounce="paperScroll" class="msg-box columnFlex flex1"> <div ref="ai-box" v-debounce="paperScroll" class="msg-box columnFlex flex1">
<div> <div>
<div v-if="!isHistory" class="rowFlex rowCenter linkStyle"> <div class="rowFlex rowCenter linkStyle">
<div class="rowFlex columnCenter"> <div class="rowFlex columnCenter">
<div class="line"></div> <div class="line"></div>
<svg-icon icon-class="start" style="margin-left:5px;" /> <svg-icon icon-class="start" style="margin-left:5px;" />
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
</div> </div>
</div> </div>
<!-- 复制客户的消息 --> <!-- 复制客户的消息 -->
<div class="likeBtn rowFlex " v-if="i.send_type == 2"> <div class=" rowFlex likeBtn " v-if="i.send_type == 2">
<span v-if="!i.loading" <span v-if="!i.loading"
style="color:#87909c;font-size:12px;margin-right:5px;">{{ style="color:#87909c;font-size:12px;margin-right:5px;">{{
i.response_time }} ms</span> i.response_time }} ms</span>
...@@ -162,8 +162,11 @@ export default { ...@@ -162,8 +162,11 @@ export default {
recordMessage: [], recordMessage: [],
aiText: '', aiText: '',
aiAnswer: {}, aiAnswer: {},
isHistory: false,
knowledge_search_list: [], knowledge_search_list: [],
page_info: {
page: 1,
page_size: 20
},
answerItem: { answerItem: {
session_id: '', session_id: '',
create_time: '', create_time: '',
...@@ -232,7 +235,7 @@ export default { ...@@ -232,7 +235,7 @@ export default {
this.recordMessage.unshift(welcomeItem) this.recordMessage.unshift(welcomeItem)
} }
}, },
async clearContext() { async clearContextComfion() {
this.$confirm('确定清除上下文吗?', '提示', { this.$confirm('确定清除上下文吗?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
...@@ -302,16 +305,14 @@ export default { ...@@ -302,16 +305,14 @@ export default {
} }
}, },
async Aihistory() { async Aihistory() {
this.recordMessage = []
const data = { const data = {
cser_id: this.userInfo.cser_id, cser_id: this.userInfo.cser_id,
page: 1, ...this.page_info
page_size: 20
} }
const res = await corp_beta_question_log_index(data) const res = await corp_beta_question_log_index(data)
if (res.status_code === 1 && res?.data?.data?.length > 0) { if (res.status_code === 1 && res?.data?.data?.length > 0) {
this.page_info.page++
res.data.data.forEach(item => { res.data.data.forEach(item => {
console.log(item, 'item')
item.to = { item.to = {
cser: { cser: {
avatar: this.chatUserInfo.avatar, avatar: this.chatUserInfo.avatar,
...@@ -328,9 +329,12 @@ export default { ...@@ -328,9 +329,12 @@ export default {
item.loading = false item.loading = false
item.is_retry = false item.is_retry = false
}) })
this.isHistory = true
this.recordMessage = res.data.data.reverse().concat(this.recordMessage) this.recordMessage = res.data.data.reverse().concat(this.recordMessage)
this.scrollBottm() if (this.page_info.page == 1) {
this.scrollBottm()
}
} else {
this.$message.warning('没有更多数据了')
} }
}, },
// 复制消息 // 复制消息
...@@ -432,16 +436,19 @@ export default { ...@@ -432,16 +436,19 @@ export default {
}) })
}, },
paperScroll() { paperScroll() {
// 监听滚动事件 if (this.userInfo.userid) {
const el = this.$refs['ai-box'] // 监听滚动事件
if (el.scrollTop <= 5 && this.isMoreRecord) { const el = this.$refs['ai-box']
this.messageList() if (el.scrollTop <= 5 && this.isMoreRecord) {
} else if (!this.isMoreRecord) { this.messageList()
// this.$message({ } else if (!this.isMoreRecord) {
// type: 'error', // this.$message({
// message: '没有更多数据了' // type: 'error',
// }) // message: '没有更多数据了'
// })
}
} }
} }
} }
} }
...@@ -531,11 +538,9 @@ export default { ...@@ -531,11 +538,9 @@ export default {
.chatItemBox { .chatItemBox {
border-radius: 10px; border-radius: 10px;
position: relative; position: relative;
width: 100%;
} }
.user-msg { .user-msg {
width: 100%;
word-break: break-all; word-break: break-all;
font-size: 14px; font-size: 14px;
line-height: 20px; line-height: 20px;
...@@ -677,9 +682,9 @@ export default { ...@@ -677,9 +682,9 @@ export default {
.likeBtn { .likeBtn {
position: absolute; position: absolute;
bottom: 5px; bottom: 5px;
right: 10px;
display: flex; display: flex;
flex-direction: row-reverse; flex-direction: row-reverse;
width: 100%;
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论