From 42bec882d8ab60507e1c40e494d3905ff565a47b Mon Sep 17 00:00:00 2001 From: STDquantum <405720329@qq.com> Date: Tue, 19 Dec 2023 00:13:39 +0800 Subject: [PATCH 1/3] =?UTF-8?q?html=E9=A1=B6=E7=AB=AF=E4=B8=8D=E6=98=AF?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=B0=B1=E5=8A=A0=E4=B8=AA=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/DataBase/output_pc.py | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/app/DataBase/output_pc.py b/app/DataBase/output_pc.py index 6027573..3169f3b 100644 --- a/app/DataBase/output_pc.py +++ b/app/DataBase/output_pc.py @@ -1140,9 +1140,31 @@ html_end = ''' return messageAudioTag; } - // 从数据列表中取出对应范围的元素并添加到容器中 + // 从数据列表中取出对应范围的元素并添加到容器中 for (let i = startIndex; i < endIndex && i < chatMessages.length; i++) { const message = chatMessages[i]; + if (i == startIndex) { // 判断一下在页面顶部多加一个时间 + if (!/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(message.text)) { + // 时间戳转成时间 + function timestampToTime(timestamp) { + let date = new Date(timestamp * 1000); + let year = date.getFullYear() + '-'; + let month = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'; + let day = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' '; + let hour = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'; + let minute = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':'; + let second = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds(); + return year + month + day + hour + minute + second; + } + + // 添加div + const newTimeMessage = document.createElement('div'); + newTimeMessage.className = "item item-center"; + newTimeMessage.innerHTML = `${timestampToTime(message.timestamp)}`; + chatContainer.appendChild(newTimeMessage); + console.log("增加时间元素", timestampToTime(message.timestamp)); + } + } const messageElement = document.createElement('div'); // 下面那俩的合体 const avatarTag = avatarBox(message); // 头像 const messageContent = document.createElement('div'); // 除了avatar之外的所有 @@ -1154,7 +1176,7 @@ html_end = ''' messageContent.appendChild(displayNameBox(message)); } messageContent.appendChild(messageBubble(message, side)); - + // 整合 messageElement.className = `item item-${side}`; messageElement.appendChild(message.is_send ? messageContent : avatarTag); @@ -1162,7 +1184,7 @@ html_end = ''' } else if (message.type == 0) { messageElement.className = "item item-center"; - messageElement.innerHTML = `${message.text}` + messageElement.innerHTML = `${message.text}`; } else if (message.type == 3) { // displayname 和 img From 9bea95f688c41b33a78ebfadb8ad843fdbe65da4 Mon Sep 17 00:00:00 2001 From: STDquantum <60764289+STDquantum@users.noreply.github.com> Date: Tue, 19 Dec 2023 14:26:15 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AF=AD=E9=9F=B3?= =?UTF-8?q?=E7=9B=B8=E5=AF=B9=E8=B7=AF=E5=BE=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/DataBase/output_pc.py | 1 + 1 file changed, 1 insertion(+) diff --git a/app/DataBase/output_pc.py b/app/DataBase/output_pc.py index 3169f3b..88d7008 100644 --- a/app/DataBase/output_pc.py +++ b/app/DataBase/output_pc.py @@ -298,6 +298,7 @@ class ChildThread(QThread): modify_audio_metadata(audio_path, displayname) os.utime(audio_path, (timestamp, timestamp)) audio_path = audio_path.replace('\\', '/') + audio_path = "./voice/" + os.path.basename(audio_path) voice_to_text = escape_js_and_html(media_msg_db.get_audio_text(str_content)) except: return From 91bc692971e104913266cf701e3cafef293cfd39 Mon Sep 17 00:00:00 2001 From: STDquantum <60764289+STDquantum@users.noreply.github.com> Date: Tue, 19 Dec 2023 14:38:32 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=B2=A1=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/DataBase/output_pc.py | 1 - 1 file changed, 1 deletion(-) diff --git a/app/DataBase/output_pc.py b/app/DataBase/output_pc.py index 88d7008..0fe28a9 100644 --- a/app/DataBase/output_pc.py +++ b/app/DataBase/output_pc.py @@ -465,7 +465,6 @@ class ChildThread(QThread): image_path = hard_link_db.get_video(str_content, BytesExtra, thumb=True) if video_path is None and image_path is not None: image_path = path.get_relative_path(image_path, base_path=f'/data/聊天记录/{self.contact.remark}/image') - image_path = image_path try: # todo 网络图片问题 print(origin_docx_path + image_path[1:])