From 3dd6a7b7c76b995f808e9dd3f56e541c4cc07cb1 Mon Sep 17 00:00:00 2001 From: linghaihui <75124771@qq.com> Date: Sun, 26 Mar 2023 01:52:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=BD=93=E5=89=8D=E4=BC=9A?= =?UTF-8?q?=E8=AF=9Dnumber?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bingchat/components/chatbox/index.wxml | 5 +- bingchat/components/chatbox/index.wxss | 64 +++++++++++++++++--------- bingchat/pages/index/index.js | 11 +++-- bingchat/pages/index/index.wxss | 4 +- new-bing/app.py | 2 + 5 files changed, 55 insertions(+), 31 deletions(-) diff --git a/bingchat/components/chatbox/index.wxml b/bingchat/components/chatbox/index.wxml index 5753398..66f3331 100644 --- a/bingchat/components/chatbox/index.wxml +++ b/bingchat/components/chatbox/index.wxml @@ -5,9 +5,8 @@ - {{item.dt}} - - + {{item.dt}}{{item.num_in_conversation}} + {{suggest}} diff --git a/bingchat/components/chatbox/index.wxss b/bingchat/components/chatbox/index.wxss index 555e4ab..544a9b1 100644 --- a/bingchat/components/chatbox/index.wxss +++ b/bingchat/components/chatbox/index.wxss @@ -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; -} \ No newline at end of file + 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; +} diff --git a/bingchat/pages/index/index.js b/bingchat/pages/index/index.js index db77c12..0afb46d 100644 --- a/bingchat/pages/index/index.js +++ b/bingchat/pages/index/index.js @@ -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, diff --git a/bingchat/pages/index/index.wxss b/bingchat/pages/index/index.wxss index 6863741..f219975 100644 --- a/bingchat/pages/index/index.wxss +++ b/bingchat/pages/index/index.wxss @@ -1,3 +1,3 @@ button::after { - border: none; -} \ No newline at end of file + border: none; +} diff --git a/new-bing/app.py b/new-bing/app.py index 0bd2d2d..d20fd90 100644 --- a/new-bing/app.py +++ b/new-bing/app.py @@ -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') })