From 88b346ae85c5121c1d15889d3f0669ed7b3fd099 Mon Sep 17 00:00:00 2001 From: linghaihui <75124771@qq.com> Date: Mon, 27 Mar 2023 00:04:32 +0800 Subject: [PATCH] Fix code --- bingchat/pages/index/index.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/bingchat/pages/index/index.js b/bingchat/pages/index/index.js index 9efe43a..f5e165b 100644 --- a/bingchat/pages/index/index.js +++ b/bingchat/pages/index/index.js @@ -9,7 +9,9 @@ function inputPop() { return systemInfo.platform == "ios" || systemInfo.platform == "android" } -const initHeight = inputPop() ? 18 : 5 +var sid_prefix = systemInfo.platform == "ios" || systemInfo.platform == "android" ? "" : systemInfo.platform + +const initHeight = inputPop() ? 20 : 5 Date.prototype.format = function (fmt) { var o = { @@ -78,7 +80,7 @@ Page({ resetConversation: function (callback) { app.getSid(sid => { doRequest("/reset", "GET", { - sid: sid, + sid: sid_prefix + sid, }).then(res => { if (callback) { callback(res) @@ -129,7 +131,7 @@ Page({ app.getSid(sid => { that.sendSocketMessage({ "q": content, - "sid": sid, + "sid": sid_prefix + sid, "t": new Date().getTime() }) }) @@ -140,7 +142,7 @@ Page({ app.getSid(sid => { doRequest("/chat", "POST", { q: content, - sid: sid, + sid: sid_prefix + sid, }).then(res => { try { var robContent = "" @@ -193,8 +195,11 @@ Page({ } else { that.pushStorageMessage(cht, "搜索中🔍...", "rob", [], true) } - // that.sendHttpRequest(content) - that.sendWSRequest(content) + if (systemInfo.platform == "ios" || systemInfo.platform == "android" || systemInfo.platform == "devtools") { + that.sendWSRequest(content) + } else { + that.sendHttpRequest(content) + } }, pushStorageMessage: function (cht, content, role, suggests, blink, pop, num_in_conversation = -1, final = true) { if (pop) { @@ -281,7 +286,8 @@ Page({ socket: { socket: null, isOpen: false - } + }, + searching: false, }) }) socket.onError(msg => { @@ -290,7 +296,8 @@ Page({ socket: { socket: null, isOpen: false - } + }, + searching: false }) }) socket.onMessage(data => {