显示当前会话number

This commit is contained in:
linghaihui 2023-03-26 01:52:27 +08:00
parent 362861f34f
commit 3dd6a7b7c7
5 changed files with 55 additions and 31 deletions

View File

@ -5,9 +5,8 @@
<view class="chat-item left" wx:if="{{item.type != 'man'}}" id="msg-{{index}}">
<image class="avatar" src="{{item.avatarUrl}}" style="display: flex;" bindlongpress="clearChat" data-index="{{index}}"></image>
<view class="chat-box" style="margin-left: 20rpx;">
<text class="dt">{{item.dt}}</text>
<view class="content bg-white" bindlongpress="copyContent" data-index="{{index}}">
<view class="{{item.blink ? 'blinking': ''}}"><mp-html content="{{item.originContent}}" preview-img markdown="{{true}}" img-cache="{{true}}" lazy-load="{{true}}" container-style="margin-top: -1em;margin-bottom:-1em;"/></view></view>
<view style="display: flex;flex-direction: row;align-items: center;"><text class="dt" style="flex: 1;">{{item.dt}}</text><view wx:if="{{item.num_in_conversation && item.num_in_conversation != -1}}" style="display:flex;justify-content:flex-end; flex: 1;align-items: center;"><text class="conversation_num">{{item.num_in_conversation}}</text></view></view>
<view class="content bg-white" bindlongpress="copyContent" data-index="{{index}}"><view class="{{item.blink ? 'blinking': ''}}"><mp-html content="{{item.originContent}}" preview-img markdown="{{true}}" img-cache="{{true}}" lazy-load="{{true}}" container-style="margin-top: -1em;margin-bottom:-1em;"/></view></view>
<view class="suggest">
<view hover-class="suggest-item-hover" class="suggest-item" bindtap="suggestSubmit" data-suggest="{{suggest}}" wx:for="{{item.suggests}}" wx:for-item="suggest">{{suggest}}</view>
</view>

View File

@ -32,8 +32,9 @@
.content {
border-radius: 16rpx;
padding: 10rpx 16rpx 10rpx 16rpx;
word-break: break-all;
white-space: pre-wrap;
word-break: break-all;
white-space: pre-wrap;
margin-top: 10rpx;
}
.bg-green {
@ -51,33 +52,52 @@
}
.suggest {
display: flex;
justify-content: flex-start;
margin-top: 8rpx;
flex-wrap: wrap;
display: flex;
justify-content: flex-start;
margin-top: 8rpx;
flex-wrap: wrap;
}
.suggest-item{
background-color: #f4f6f8;
display: inline-block;
padding: 5rpx 8rpx 5rpx 8rpx;
border-radius: 8rpx;
margin-right: 16rpx;
color: #b4bbc4;
margin-bottom: 10rpx;
font-size: 24rpx;
.suggest-item {
background-color: #f4f6f8;
display: inline-block;
padding: 5rpx 8rpx 5rpx 8rpx;
border-radius: 8rpx;
margin-right: 16rpx;
color: #b4bbc4;
margin-bottom: 10rpx;
font-size: 24rpx;
}
@keyframes blink {
from { display: 1.0; }
to { opacity: 0.0; }
from {
display: 1.0;
}
to {
opacity: 0.0;
}
}
.blinking {
animation: blink 1.5s ease-in-out infinite;
display: block;
animation: blink 1.5s ease-in-out infinite;
display: block;
}
.suggest-item-hover {
color: #ff502c;
cursor: pointer;
}
color: #ff502c;
cursor: pointer;
}
.conversation_num {
color: white;
background: #b4bbc4;
display: inline-block;
text-align: center;
border-radius: 50%;
width: 2em;
height: 2em;
font-size: 16rpx;
line-height: 2em;
opacity: 0.7;
}

View File

@ -120,8 +120,9 @@ Page({
sid: sid,
}).then(res => {
try {
var robContent = "";
var suggests = [];
var robContent = ""
var suggests = []
var num_in_conversation = -1
if (res.statusCode != 200) {
robContent =
"抱歉😭,网络异常,请稍后重试 [" + res.statusCode + "]";
@ -136,6 +137,7 @@ Page({
suggests.push("重新对话!");
suggests.push(content);
}
num_in_conversation = res.data["data"]["num_in_conversation"];
} else {
if (robContent == "Throttled") {
robContent = "这真是愉快,但你已达到每日限制。是否明天再聊?";
@ -154,7 +156,7 @@ Page({
}
}
}
that.pushStorageMessage(cht, robContent, "rob", suggests, false, true)
that.pushStorageMessage(cht, robContent, "rob", suggests, false, true, num_in_conversation)
} catch (error) {
wx.showToast({
title: "fatal error",
@ -166,7 +168,7 @@ Page({
})
})
},
pushStorageMessage: function (cht, content, role, suggests, blink, pop) {
pushStorageMessage: function (cht, content, role, suggests, blink, pop, num_in_conversation = -1) {
if (pop) {
cht.data.chatList.pop();
}
@ -177,6 +179,7 @@ Page({
originContent: this.processContent(content),
suggests: suggests,
blink: blink,
num_in_conversation: num_in_conversation,
});
cht.setData({
chatList: cht.data.chatList,

View File

@ -1,3 +1,3 @@
button::after {
border: none;
}
border: none;
}

View File

@ -90,6 +90,8 @@ async def chat(request):
'text': text,
'suggests': suggests,
'message': msg,
'num_in_conversation': res['item']['throttling']['numUserMessagesInConversation'] if 'throttling' in
res['item'] else -1,
},
'cookie': os.environ.get('COOKIE_FILE')
})