Feat(云灵AI):对话接口对接完成
This commit is contained in:
@@ -0,0 +1,349 @@
|
||||
<template>
|
||||
<view
|
||||
:class="scrollTop > 0 ? 'page-scroll' : ''"
|
||||
class="fix-tabbar-page"
|
||||
>
|
||||
<hx-navbar
|
||||
:back="true"
|
||||
:fixed="true"
|
||||
:statusBar="true"
|
||||
:pageScroll.sync="scrollData"
|
||||
:title="pageTitle"
|
||||
color="#333"
|
||||
transparent="auto"
|
||||
barPlaceholder="hidden"
|
||||
/>
|
||||
<view
|
||||
id="fixTbabarBody"
|
||||
:style="{
|
||||
'padding-top': (44 + statusBarHeight) + 'px'
|
||||
}"
|
||||
class="fix-tabbar-body"
|
||||
>
|
||||
<view class="chat-wrap">
|
||||
<view v-if="chatMessageListLength > 0" class="chat-list-wrap">
|
||||
<view
|
||||
v-for="(item, index) in chatMessageList"
|
||||
:key="index"
|
||||
class="chat-message-item"
|
||||
>
|
||||
<view v-if="item.type === -1" class="chat-message-body">
|
||||
<view class="item-right">
|
||||
<view class="txt">
|
||||
{{ item.prompt }}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="item.type === -2" class="chat-message-body">
|
||||
<view class="avatar">
|
||||
<image
|
||||
:src="webUrl + '/aiChat/avatar.png'"
|
||||
class="chat-avatar"
|
||||
mode="widthFix"
|
||||
/>
|
||||
</view>
|
||||
<view class="item-left">
|
||||
<view class="txt">
|
||||
<view
|
||||
ref="rich-text-box"
|
||||
:class="{
|
||||
'show-cursor': item.showCursor
|
||||
}"
|
||||
class="rich-text-box"
|
||||
>
|
||||
<rich-text
|
||||
v-if="item.nodes && item.nodes.length"
|
||||
:nodes="item.nodes"
|
||||
space="nbsp"
|
||||
/>
|
||||
<view v-if="!(item.nodes && item.nodes.length) && loading" class="loader-wrap">
|
||||
<div class="loader" />
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="!item.showCursor && item.nodes && item.nodes.length && !item.isError"
|
||||
class="bottom-btns"
|
||||
>
|
||||
<!-- <button
|
||||
open-type="share"
|
||||
plain="true"
|
||||
class="item"
|
||||
@click="shareHandle"
|
||||
>
|
||||
<image
|
||||
:src="webUrl + '/icon-25.png'"
|
||||
class="icon"
|
||||
mode="widthFix"
|
||||
/>
|
||||
分享
|
||||
</button> -->
|
||||
<view class="item" @click="copyContentHandle(item.content)">
|
||||
<image
|
||||
:src="webUrl + '/aiChat/icon-02.png'"
|
||||
class="icon"
|
||||
mode="widthFix"
|
||||
/>
|
||||
复制
|
||||
</view>
|
||||
<view
|
||||
v-if="index === (chatMessageListLength - 1)"
|
||||
class="item"
|
||||
@click="regenerateHandle(item)"
|
||||
>
|
||||
<image
|
||||
:src="webUrl + '/aiChat/icon-04.png'"
|
||||
class="icon"
|
||||
mode="widthFix"
|
||||
/>
|
||||
重新生成
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="index === (chatMessageListLength - 1) && item.listQuestion.length > 0"
|
||||
class="suggestion-wrap"
|
||||
>
|
||||
<view class="suggestion-list">
|
||||
<view
|
||||
v-for="(question, questionIndex) in item.listQuestion"
|
||||
:key="questionIndex"
|
||||
class="item"
|
||||
@click="suggestionItemClickHandle(question)"
|
||||
>
|
||||
<view class="item-cont">
|
||||
<view class="txt">
|
||||
{{ question }}
|
||||
</view>
|
||||
<image
|
||||
:src="webUrl + '/aiChat/icon-03.png'"
|
||||
class="pic"
|
||||
mode="widthFix"
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view id="bottom_postion" class="bottom-postion" />
|
||||
</view>
|
||||
</view>
|
||||
<view class="page-to-bottom">
|
||||
<image
|
||||
v-if="chatMessageListLength > 0 && !isScrollToBottom && !loading"
|
||||
:src="webUrl + '/aiChat/down.png'"
|
||||
class="icon"
|
||||
mode="widthFix"
|
||||
@click="scrollToBottomHandle"
|
||||
/>
|
||||
</view>
|
||||
<bottom-send
|
||||
ref="bottomSend"
|
||||
:loading="loading"
|
||||
@send="streamReq"
|
||||
@history="historyViewHandle"
|
||||
/>
|
||||
<AiHistoryList
|
||||
ref="historyView"
|
||||
:status-bar-height="statusBarHeight"
|
||||
form-module="history"
|
||||
/>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { chatMixins } from '../mixins/chatMixins.js'
|
||||
import AiHistoryList from '../components/historyList'
|
||||
import BottomSend from '../components/bottomSend.vue'
|
||||
import {
|
||||
historyChatMessage
|
||||
} from '@/api/chat/index'
|
||||
import { formatAiMsgContent } from '../utils/aiChat'
|
||||
export default {
|
||||
name: 'AiChatHistoryPage',
|
||||
components: {
|
||||
AiHistoryList,
|
||||
BottomSend
|
||||
},
|
||||
mixins: [chatMixins],
|
||||
data() {
|
||||
return {
|
||||
pageTitle: ''
|
||||
}
|
||||
},
|
||||
onLoad(optisons) {
|
||||
console.log(optisons)
|
||||
this.chatNumber = optisons.chatNumber
|
||||
this.pageTitle = optisons.title
|
||||
this.init()
|
||||
},
|
||||
methods: {
|
||||
init() {
|
||||
this.loading = true
|
||||
historyChatMessage({
|
||||
chatNumber: this.chatNumber
|
||||
}).then(res => {
|
||||
const { success, data = [] } = res
|
||||
if (success) {
|
||||
this.loading = false
|
||||
try {
|
||||
data.map(item => {
|
||||
if (item.role === 'user') {
|
||||
this.chatMessageList.push({
|
||||
type: -1,
|
||||
prompt: item.content
|
||||
})
|
||||
} else {
|
||||
if (item.contentType === 'text') {
|
||||
this.chatMessageList.push({
|
||||
...item,
|
||||
nodes: formatAiMsgContent(item.content),
|
||||
prompt: this.getParentPrompt(data, item.parentMessageId),
|
||||
conversationId: item.messageId,
|
||||
showCursor: false,
|
||||
listQuestion: item.listQuestion || [],
|
||||
type: -2
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
uni.showModal({
|
||||
title: '错误提示',
|
||||
content: JSON.stringify(err)
|
||||
})
|
||||
console.log(err)
|
||||
}
|
||||
}
|
||||
}).catch(() => {
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
getParentPrompt(list = '', parentMessageId) {
|
||||
let prompt = ''
|
||||
list.map(item => {
|
||||
if (item.messageId === parentMessageId) {
|
||||
prompt = item.content
|
||||
}
|
||||
})
|
||||
return prompt
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.chat-wrap {
|
||||
padding: 0 0 180rpx 0;
|
||||
.chat-info-wrap {
|
||||
padding: 24rpx;
|
||||
.chat-list-wrap2 {
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
.loading-wrap {
|
||||
text-align: center;
|
||||
color: #666;
|
||||
line-height: 120rpx;
|
||||
}
|
||||
.rich-text-box {
|
||||
max-width: 100%;
|
||||
}
|
||||
.show-cursor .cursor {
|
||||
display: inline-block;
|
||||
color: #3D4CF1;
|
||||
font-weight: bold;
|
||||
animation: blinking 1s infinite;
|
||||
}
|
||||
|
||||
@keyframes blinking {
|
||||
from {
|
||||
opacity: 1.0;
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 0.0;
|
||||
}
|
||||
}
|
||||
.focus-guide-wrap {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 60rpx 40rpx;
|
||||
.guide-left {
|
||||
.avatar {
|
||||
display: block;
|
||||
width: 267rpx;
|
||||
height: 530rpx;
|
||||
}
|
||||
}
|
||||
.guide-right {
|
||||
padding: 30rpx;
|
||||
margin: 0 0 0 40rpx;
|
||||
border-radius: 20rpx;
|
||||
font-size: 24rpx;
|
||||
background-color: #fff;
|
||||
box-shadow: 0rpx 12rpx 30rpx rgba(0,0,0,0.1);
|
||||
.title {
|
||||
font-weight: bold;
|
||||
}
|
||||
.content {
|
||||
padding: 30rpx 0 0 0;
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
}
|
||||
.topic-wrap {
|
||||
width: 100%;
|
||||
.title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
.txt {
|
||||
width: 186rpx;
|
||||
height: 46rpx;
|
||||
margin: 0 20rpx;
|
||||
border-radius: 24rpx;
|
||||
text-align: center;
|
||||
line-height: 46rpx;
|
||||
color: #fff;
|
||||
font-size: 26rpx;
|
||||
background-color: #3D4CF1;
|
||||
}
|
||||
.icon {
|
||||
display: flex;
|
||||
width: 40rpx;
|
||||
}
|
||||
}
|
||||
.list-wrap {
|
||||
width: 100%;
|
||||
margin: 60rpx 0 0 0;
|
||||
overflow-x: auto;
|
||||
.list-cont {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
width: 150%;
|
||||
.list-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 40rpx;
|
||||
padding: 0 12rpx;
|
||||
margin: 0 30rpx 30rpx 0;
|
||||
border-radius: 20rpx;
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
background: rgba(255,255,255,0.39);
|
||||
box-shadow: 0rpx 6rpx 12rpx rgba(0,0,0,0.1);
|
||||
.icon {
|
||||
display: block;
|
||||
width: 24rpx;
|
||||
height: 24rpx;
|
||||
margin: 0 8rpx 0 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -209,7 +209,7 @@
|
||||
@history="historyViewHandle"
|
||||
/>
|
||||
<AiHistoryList
|
||||
ref="history"
|
||||
ref="historyView"
|
||||
:status-bar-height="statusBarHeight"
|
||||
/>
|
||||
</view>
|
||||
@@ -233,9 +233,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
settingInfo: {},
|
||||
topicList: [],
|
||||
historyList: [],
|
||||
moreList: []
|
||||
topicList: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -264,9 +262,6 @@ export default {
|
||||
this.loading = false
|
||||
this.getConfigLoading = false
|
||||
this.chatMessageList = []
|
||||
},
|
||||
historyViewHandle() {
|
||||
this.$refs.history.showView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user