mirror of
https://github.com/LC044/WeChatMsg
synced 2024-11-12 20:21:21 +08:00
修改文件
This commit is contained in:
parent
d37f75da00
commit
e389065539
@ -16,7 +16,7 @@ def get_ffmpeg_path():
|
||||
resource_dir = getattr(sys, '_MEIPASS', os.path.abspath(os.path.dirname(__file__)))
|
||||
|
||||
# 构建 FFmpeg 可执行文件的路径
|
||||
ffmpeg_path = os.path.join(resource_dir, 'app', 'resources', 'ffmpeg.exe')
|
||||
ffmpeg_path = os.path.join(resource_dir, 'app', 'resources','data', 'ffmpeg.exe')
|
||||
|
||||
return ffmpeg_path
|
||||
|
||||
@ -92,11 +92,11 @@ class MediaMsg:
|
||||
else:
|
||||
# 源码运行的时候下面的有效
|
||||
# 这里不知道怎么捕捉异常
|
||||
cmd = f'''{os.path.join(os.getcwd(), 'app', 'resources', 'ffmpeg.exe')} -loglevel quiet -y -f s16le -i {pcm_path} -ar 44100 -ac 1 {mp3_path}'''
|
||||
cmd = f'''{os.path.join(os.getcwd(), 'app', 'resources', 'data','ffmpeg.exe')} -loglevel quiet -y -f s16le -i {pcm_path} -ar 44100 -ac 1 {mp3_path}'''
|
||||
system(cmd)
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
cmd = f'''{os.path.join(os.getcwd(), 'app', 'resources', 'ffmpeg.exe')} -loglevel quiet -y -f s16le -i {pcm_path} -ar 44100 -ac 1 {mp3_path}'''
|
||||
cmd = f'''{os.path.join(os.getcwd(), 'app', 'resources', 'data', 'ffmpeg.exe')} -loglevel quiet -y -f s16le -i {pcm_path} -ar 44100 -ac 1 {mp3_path}'''
|
||||
system(cmd)
|
||||
system(f'del {silk_path}')
|
||||
system(f'del {pcm_path}')
|
||||
|
@ -31,6 +31,11 @@ def makedirs(path):
|
||||
os.makedirs(os.path.join(path, 'voice'), exist_ok=True)
|
||||
os.makedirs(os.path.join(path, 'file'), exist_ok=True)
|
||||
os.makedirs(os.path.join(path, 'avatar'), exist_ok=True)
|
||||
file = './app/resources/data/file.png'
|
||||
if not os.path.exists(file):
|
||||
resource_dir = getattr(sys, '_MEIPASS', os.path.abspath(os.path.dirname(__file__)))
|
||||
file = os.path.join(resource_dir, 'app', 'resources', 'data','file.png')
|
||||
shutil.copy(file, path + '/file/file.png')
|
||||
|
||||
|
||||
def escape_js_and_html(input_str):
|
||||
@ -383,7 +388,6 @@ class ChildThread(QThread):
|
||||
if self.output_type == Output.HTML:
|
||||
link = get_file(bytesExtra, thumb=True, output_path=origin_docx_path + '/file')
|
||||
file_name = ''
|
||||
shutil.copy(f"{os.path.abspath('.')}/app/resources/icons/file.png", origin_docx_path + '/file/file.png')
|
||||
file_path = './file/file.png'
|
||||
if link != "":
|
||||
file_name = os.path.basename(link)
|
||||
@ -544,16 +548,18 @@ class ChildThread(QThread):
|
||||
def to_html_(self):
|
||||
origin_docx_path = f"{os.path.abspath('.')}/data/聊天记录/{self.contact.remark}"
|
||||
makedirs(origin_docx_path)
|
||||
|
||||
if self.contact.is_chatroom:
|
||||
packagemsg = PackageMsg()
|
||||
messages = packagemsg.get_package_message_by_wxid(self.contact.wxid)
|
||||
else:
|
||||
messages = msg_db.get_messages(self.contact.wxid)
|
||||
filename = f"{os.path.abspath('.')}/data/聊天记录/{self.contact.remark}/{self.contact.remark}.html"
|
||||
file_path = './app/resources/template.html'
|
||||
file_path = './app/resources/data/template.html'
|
||||
if not os.path.exists(file_path):
|
||||
resource_dir = getattr(sys, '_MEIPASS', os.path.abspath(os.path.dirname(__file__)))
|
||||
file_path = os.path.join(resource_dir, 'app', 'resources', 'template.html')
|
||||
file_path = os.path.join(resource_dir, 'app', 'resources', 'data','template.html')
|
||||
|
||||
with open(file_path, "r", encoding="utf-8") as f:
|
||||
content = f.read()
|
||||
html_head, html_end = content.split('/*注意看这是分割线*/')
|
||||
@ -688,7 +694,8 @@ class OutputEmoji(QThread):
|
||||
for message in messages:
|
||||
str_content = message[7]
|
||||
try:
|
||||
emoji_path = get_emoji(str_content, thumb=True, output_path=origin_docx_path + '/emoji')
|
||||
pass
|
||||
# emoji_path = get_emoji(str_content, thumb=True, output_path=origin_docx_path + '/emoji')
|
||||
except:
|
||||
logger.error(traceback.format_exc())
|
||||
finally:
|
||||
|
@ -96,10 +96,10 @@ def wordcloud_christmas(wxid, year='2023'):
|
||||
stopwords1 = set(stopword_file.read().splitlines())
|
||||
# 构建 FFmpeg 可执行文件的路径
|
||||
stopwords = set()
|
||||
stopwords_file = './app/resources/stopwords.txt'
|
||||
stopwords_file = './app/resources/data/stopwords.txt'
|
||||
if not os.path.exists(stopwords_file):
|
||||
resource_dir = getattr(sys, '_MEIPASS', os.path.abspath(os.path.dirname(__file__)))
|
||||
stopwords_file = os.path.join(resource_dir, 'app', 'resources', 'stopwords.txt')
|
||||
stopwords_file = os.path.join(resource_dir, 'app', 'resources', 'data','stopwords.txt')
|
||||
with open(stopwords_file, "r", encoding="utf-8") as stopword_file:
|
||||
stopwords = set(stopword_file.read().splitlines())
|
||||
stopwords = stopwords.union(stopwords1)
|
||||
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 568 B |
File diff suppressed because it is too large
Load Diff
@ -1,799 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Chat Records</title>
|
||||
<style>
|
||||
*{
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
body{
|
||||
height: 100vh;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
z-index: 9999;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.8);
|
||||
}
|
||||
|
||||
.modal-image {
|
||||
display: block;
|
||||
max-width: 90%;
|
||||
max-height: 90%;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
.container{
|
||||
height: 99%;
|
||||
width: 900px;
|
||||
border-radius: 4px;
|
||||
border: 0.5px solid #e0e0e0;
|
||||
background-color: #f5f5f5;
|
||||
display: flex;
|
||||
flex-flow: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
.content{
|
||||
width: calc(100% - 40px);
|
||||
padding: 20px;
|
||||
overflow-y: scroll;
|
||||
flex: 1;
|
||||
}
|
||||
.content:hover::-webkit-scrollbar-thumb{
|
||||
background:rgba(0,0,0,0.1);
|
||||
}
|
||||
.bubble{
|
||||
max-width: 400px;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
position: relative;
|
||||
color: #000;
|
||||
word-wrap:break-word;
|
||||
word-break:normal;
|
||||
}
|
||||
.chat-refer {
|
||||
margin-top: 5px;
|
||||
max-width: 400px;
|
||||
padding: 9px;
|
||||
border-radius: 5px;
|
||||
position: relative;
|
||||
color: #000;
|
||||
background-color: #e8e8e8;
|
||||
word-wrap:break-word;
|
||||
word-break:normal;
|
||||
}
|
||||
.chat-refer-right {
|
||||
margin-right: 15px;
|
||||
}
|
||||
.chat-refer-left{
|
||||
margin-left: 15px;
|
||||
}
|
||||
.item-left .bubble{
|
||||
margin-left: 15px;
|
||||
background-color: #fff;
|
||||
}
|
||||
.item-left .bubble:before{
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-left: 10px solid transparent;
|
||||
border-top: 10px solid transparent;
|
||||
border-right: 10px solid #fff;
|
||||
border-bottom: 10px solid transparent;
|
||||
left: -20px;
|
||||
}
|
||||
.item-right .bubble{
|
||||
margin-right: 15px;
|
||||
background-color: #9eea6a;
|
||||
}
|
||||
.item-right .bubble:before{
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-left: 10px solid #9eea6a;
|
||||
border-top: 10px solid transparent;
|
||||
border-right: 10px solid transparent;
|
||||
border-bottom: 10px solid transparent;
|
||||
right: -20px;
|
||||
}
|
||||
.item {
|
||||
white-space: pre-wrap;
|
||||
margin-top: 15px;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
}
|
||||
.item-refer{
|
||||
margin-top: 4px;
|
||||
}
|
||||
.item.item-right{
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.item.item-center{
|
||||
justify-content: center;
|
||||
}
|
||||
.item.item-center span{
|
||||
font-size: 12px;
|
||||
padding: 2px 4px;
|
||||
color: #fff;
|
||||
background-color: #dadada;
|
||||
border-radius: 3px;
|
||||
-moz-user-select:none; /*火狐*/
|
||||
-webkit-user-select:none; /*webkit浏览器*/
|
||||
-ms-user-select:none; /*IE10*/
|
||||
-khtml-user-select:none; /*早期浏览器*/
|
||||
user-select:none;
|
||||
}
|
||||
|
||||
.content-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.content-wrapper-left {
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
.content-wrapper-right {
|
||||
align-items: flex-end;
|
||||
}
|
||||
|
||||
.displayname {
|
||||
margin-left: 13px;
|
||||
margin-left: 13px;
|
||||
font-size: 13px;
|
||||
margin-bottom: 5px;
|
||||
color: darkgray;
|
||||
}
|
||||
|
||||
.chat-image img,.chat-file img{
|
||||
margin-right: 18px;
|
||||
margin-left: 18px;
|
||||
max-width: 300px;
|
||||
max-height: auto;
|
||||
}
|
||||
.avatar img{
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
.chat-video video{
|
||||
margin-right: 18px;
|
||||
margin-left: 18px;
|
||||
max-width: 350px;
|
||||
}
|
||||
.chat-audio{
|
||||
max-width: 400px;
|
||||
}
|
||||
audio{
|
||||
margin-left: 9px;
|
||||
margin-right: 9px;
|
||||
}
|
||||
|
||||
.chat-file {
|
||||
width: 300px;
|
||||
background-color: #fff;
|
||||
margin-right: 20px;
|
||||
}
|
||||
.chat-file a ,.chat-file div{
|
||||
display: flex;
|
||||
color: #000;
|
||||
outline: none;
|
||||
text-decoration: none;
|
||||
margin: 0 20px 20px 20px;
|
||||
}
|
||||
.chat-file div{
|
||||
margin: 20px;
|
||||
}
|
||||
.chat-file a span ,.chat-file div span{
|
||||
/* flex-grow: 1; */
|
||||
width: 200px;
|
||||
}
|
||||
.chat-file a img,.chat-file div img{
|
||||
width: 100px;
|
||||
}
|
||||
.input-area{
|
||||
border-top:0.5px solid #e0e0e0;
|
||||
height: 150px;
|
||||
display: flex;
|
||||
flex-flow: column;
|
||||
background-color: #fff;
|
||||
}
|
||||
textarea{
|
||||
flex: 1;
|
||||
padding: 5px;
|
||||
font-size: 14px;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
outline:none;
|
||||
resize:none;
|
||||
}
|
||||
.button-area{
|
||||
display: flex;
|
||||
height: 40px;
|
||||
margin-right: 10px;
|
||||
line-height: 40px;
|
||||
padding: 5px;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.button-area button{
|
||||
width: 80px;
|
||||
border: none;
|
||||
outline: none;
|
||||
border-radius: 4px;
|
||||
float: right;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* 设置滚动条的样式 */
|
||||
::-webkit-scrollbar {
|
||||
width:10px;
|
||||
}
|
||||
/* 滚动槽 */
|
||||
::-webkit-scrollbar-track {
|
||||
-webkit-box-shadow:inset006pxrgba(0,0,0,0.3);
|
||||
border-radius:8px;
|
||||
}
|
||||
/* 滚动条滑块 */
|
||||
::-webkit-scrollbar-thumb {
|
||||
border-radius:10px;
|
||||
background:rgba(0,0,0,0);
|
||||
-webkit-box-shadow:inset006pxrgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
margin-top: 20px;
|
||||
margin-left: 20px; /* 新增的左边距 */
|
||||
}
|
||||
|
||||
.button-row,
|
||||
.jump-row,
|
||||
#paginationInfo {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 10px 25px;
|
||||
background-color: #3498db;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
margin: 0 14px;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #2980b9;
|
||||
}
|
||||
|
||||
input {
|
||||
padding: 8px;
|
||||
width: 120px;
|
||||
box-sizing: border-box;
|
||||
margin-right: 0px;
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
button,
|
||||
input {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
#paginationInfo {
|
||||
color: #555;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.emoji_img {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
vertical-align: middle;
|
||||
margin-top: -4.4px;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="content" id="chat-container" onscroll="checkScroll()">
|
||||
<div class="item item-center"><span>昨天 12:35</span></div>
|
||||
<div class="item item-center"><span>你已添加了凡繁烦,现在可以开始聊天了。</span></div>
|
||||
<div class="item item-left">
|
||||
<div class="avatar">
|
||||
<img src="https://dss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=25668084,2889217189&fm=26&gp=0.jpg" />
|
||||
</div>
|
||||
<div class="bubble bubble-left">您好,我在武汉,你可以直接送过来吗,我有时间的话,可以自己过去拿<br/>!!!<br/>123
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="item item-right">
|
||||
<div class="bubble bubble-right">hello<br/>你好呀</div>
|
||||
<div class="avatar">
|
||||
<img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3313909130,2406410525&fm=15&gp=0.jpg" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="item item-center">
|
||||
<span>昨天 13:15</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div></div>
|
||||
<div id="modal" class="modal" onclick="hideModal()">
|
||||
<img id="modal-image" class="modal-image">
|
||||
</div>
|
||||
<div class="pagination-container">
|
||||
<div class="button-row">
|
||||
<button onclick="prevPage()">上一页</button>
|
||||
<button onclick="nextPage()">下一页</button>
|
||||
</div>
|
||||
<div class="jump-row">
|
||||
<input type="number" id="gotoPageInput" onkeydown="checkEnter(event)" placeholder="跳转到第几页">
|
||||
<button onclick="gotoPage()">跳转</button>
|
||||
</div>
|
||||
<div id="paginationInfo"></div>
|
||||
</div>
|
||||
<script>
|
||||
const chatContainer = document.getElementById('chat-container');
|
||||
// Sample chat messages (replace this with your actual data)
|
||||
const chatMessages = [
|
||||
/*注意看这是分割线*/
|
||||
];
|
||||
function checkEnter(event) {
|
||||
if (event.keyCode === 13) {
|
||||
gotoPage();
|
||||
}
|
||||
}
|
||||
|
||||
const itemsPerPage = 100; // 每页显示的元素个数
|
||||
let currentPage = 1; // 当前页
|
||||
var reachedBottom = false; // 到达底部的标记
|
||||
var lastScrollTop = 0;
|
||||
function renderPage(page) {
|
||||
const container = document.getElementById('chat-container');
|
||||
if (!reachedBottom) {
|
||||
container.innerHTML = ''; // 清空容器
|
||||
lastScrollTop = 0;
|
||||
} else {
|
||||
reachedBottom = false;
|
||||
}
|
||||
|
||||
// 计算当前页应该显示的元素范围
|
||||
const startIndex = (page - 1) * itemsPerPage;
|
||||
const endIndex = startIndex + itemsPerPage;
|
||||
|
||||
function replaceEmoji(text){
|
||||
|
||||
// 定义替换规则,可以根据需要添加更多规则
|
||||
var replacementRules = [
|
||||
{ pattern: /\[微笑\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_1@2x.png" id="微笑" class="emoji_img">' },
|
||||
{ pattern: /\[发呆\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_4@2x.png" id="发呆" class="emoji_img">' },
|
||||
{pattern: /\[撇嘴\]/g,replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_2@2x.png" id="撇嘴" class="emoji_img">'},
|
||||
{pattern: /\[色\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_3@2x.png" id="色" class="emoji_img">'},
|
||||
{pattern: /\[发呆\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_4@2x.png" id="发呆" class="emoji_img">'},
|
||||
{pattern: /\[得意\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_5@2x.png" id="得意" class="emoji_img">'},
|
||||
{pattern: /\[流泪\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_6@2x.png" id="流泪" class="emoji_img">'},
|
||||
{pattern: /\[害羞\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_7@2x.png" id="害羞" class="emoji_img">'},
|
||||
{pattern: /\[闭嘴\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_8@2x.png" id="闭嘴" class="emoji_img">'},
|
||||
{pattern: /\[睡\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_9@2x.png" id="睡" class="emoji_img">'},
|
||||
{pattern: /\[大哭\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_10@2x.png" id="大哭" class="emoji_img">'},
|
||||
{pattern: /\[尴尬\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_11@2x.png" id="尴尬" class="emoji_img">'},
|
||||
{pattern: /\[发怒\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_12@2x.png" id="发怒" class="emoji_img">'},
|
||||
{pattern: /\[调皮\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_13@2x.png" id="调皮" class="emoji_img">'},
|
||||
{pattern: /\[呲牙\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_14@2x.png" id="呲牙" class="emoji_img">'},
|
||||
{pattern: /\[惊讶\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_15@2x.png" id="惊讶" class="emoji_img">'},
|
||||
{pattern: /\[难过\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_16@2x.png" id="难过" class="emoji_img">'},
|
||||
{pattern: /\[抓狂\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_19@2x.png" id="抓狂" class="emoji_img">'},
|
||||
{pattern: /\[吐\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_20@2x.png" id="吐" class="emoji_img">'},
|
||||
{pattern: /\[偷笑\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_21@2x.png" id="偷笑" class="emoji_img">'},
|
||||
{pattern: /\[愉快\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_22@2x.png" id="愉快" class="emoji_img">'},
|
||||
{pattern: /\[白眼\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_23@2x.png" id="白 眼" class="emoji_img">'},
|
||||
{pattern: /\[傲慢\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_24@2x.png" id="傲慢" class="emoji_img">'},
|
||||
{pattern: /\[困\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_26@2x.png" id="困" class="emoji_img">'},
|
||||
{pattern: /\[惊恐\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_27@2x.png" id="惊恐" class="emoji_img">'},
|
||||
{pattern: /\[憨笑\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_29@2x.png" id="憨笑" class="emoji_img">'},
|
||||
{pattern: /\[悠闲\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_30@2x.png" id="悠闲" class="emoji_img">'},
|
||||
{pattern: /\[咒骂\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_32@2x.png" id="咒骂" class="emoji_img">'},
|
||||
{pattern: /\[疑问\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_33@2x.png" id="疑问" class="emoji_img">'},
|
||||
{pattern: /\[嘘\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_34@2x.png" id="嘘" class="emoji_img">'},
|
||||
{pattern: /\[晕\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_35@2x.png" id="晕" class="emoji_img">'},
|
||||
{pattern: /\[衰\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_37@2x.png" id="衰" class="emoji_img">'},
|
||||
{pattern: /\[骷髅\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_38@2x.png" id="骷髅" class="emoji_img">'},
|
||||
{pattern: /\[敲打\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_39@2x.png" id="敲打" class="emoji_img">'},
|
||||
{pattern: /\[再见\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_40@2x.png" id="再见" class="emoji_img">'},
|
||||
{pattern: /\[擦汗\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_41@2x.png" id="擦汗" class="emoji_img">'},
|
||||
{pattern: /\[抠鼻\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_42@2x.png" id="抠鼻" class="emoji_img">'},
|
||||
{pattern: /\[鼓掌\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_43@2x.png" id="鼓掌" class="emoji_img">'},
|
||||
{pattern: /\[坏笑\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_45@2x.png" id="坏笑" class="emoji_img">'},
|
||||
{pattern: /\[右哼哼\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_47@2x.png" id="右哼哼" class="emoji_img">'},
|
||||
{pattern: /\[鄙视\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_49@2x.png" id="鄙视" class="emoji_img">'},
|
||||
{pattern: /\[委屈\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_50@2x.png" id="委屈" class="emoji_img">'},
|
||||
{pattern: /\[快哭了\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_51@2x.png" id="快哭了" class="emoji_img">'},
|
||||
{pattern: /\[阴险\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_52@2x.png" id="阴险" class="emoji_img">'},
|
||||
{pattern: /\[亲亲\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_53@2x.png" id="亲亲" class="emoji_img">'},
|
||||
{pattern: /\[可怜\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_55@2x.png" id="可怜" class="emoji_img">'},
|
||||
{pattern: /\[Whimper\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_55@2x.png" id="可怜" class="emoji_img">'},
|
||||
{pattern: /\[笑脸\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Happy.png" id="笑脸" class="emoji_img">'},
|
||||
{pattern: /\[生病\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Sick.png" id="生病" class="emoji_img">'},
|
||||
{pattern: /\[脸红\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Flushed.png" id="脸红" class="emoji_img">'},
|
||||
{pattern: /\[破涕为笑\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Lol.png" id="破涕为笑" class="emoji_img">'},
|
||||
{pattern: /\[恐惧\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Terror.png" id="恐惧" class="emoji_img">'},
|
||||
{pattern: /\[失望\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/LetDown.png" id="失望" class="emoji_img">'},
|
||||
{pattern: /\[无语\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Duh.png" id="无语" class="emoji_img">'},
|
||||
{pattern: /\[嘿哈\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/2_04.png" id="嘿哈" class="emoji_img">'},
|
||||
{pattern: /\[捂脸\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/2_05.png" id="捂脸" class="emoji_img">'},
|
||||
{pattern: /\[奸笑\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/2_02.png" id="奸笑" class="emoji_img">'},
|
||||
{pattern: /\[机智\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/2_06.png" id="机智" class="emoji_img">'},
|
||||
{pattern: /\[皱眉\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/2_12.png" id="皱眉" class="emoji_img">'},
|
||||
{pattern: /\[耶\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/2_11.png" id="耶" class="emoji_img">'},
|
||||
{pattern: /\[吃瓜\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Watermelon.png" id="吃瓜" class="emoji_img">'},
|
||||
{pattern: /\[加油\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Addoil.png" id="加油" class="emoji_img">'},
|
||||
{pattern: /\[汗\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Sweat.png" id="汗" class="emoji_img">'},
|
||||
{pattern: /\[天啊\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Shocked.png" id="天啊" class="emoji_img">'},
|
||||
{pattern: /\[Emm\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Cold.png" id="Emm" class="emoji_img">'},
|
||||
{pattern: /\[社会社会\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Social.png" id="社会社会" class="emoji_img">'},
|
||||
{pattern: /\[旺柴\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Yellowdog.png" id="旺柴" class="emoji_img">'},
|
||||
{pattern: /\[好的\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/NoProb.png" id="好的" class="emoji_img">'},
|
||||
{pattern: /\[打脸\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Slap.png" id="打脸" class="emoji_img">'},
|
||||
{pattern: /\[哇\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Wow.png" id="哇" class="emoji_img">'},
|
||||
{pattern: /\[翻白眼\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Boring.png" id="翻白眼" class="emoji_img">'},
|
||||
{pattern: /\[666\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/666.png" id="666" class="emoji_img">'},
|
||||
{pattern: /\[让我看看\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/LetMeSee.png" id="让我看看" class="emoji_img">'},
|
||||
{pattern: /\[叹气\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Sigh.png" id="叹气" class="emoji_img">'},
|
||||
{pattern: /\[苦涩\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Hurt.png" id="苦涩" class="emoji_img">'},
|
||||
{pattern: /\[裂开\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Broken.png" id="裂开" class="emoji_img">'},
|
||||
{pattern: /\[嘴唇\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_66@2x.png" id="嘴唇" class="emoji_img">'},
|
||||
{pattern: /\[爱心\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_67@2x.png" id="爱心" class="emoji_img">'},
|
||||
{pattern: /\[心碎\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_68@2x.png" id="心碎" class="emoji_img">'},
|
||||
{pattern: /\[拥抱\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_79@2x.png" id="拥抱" class="emoji_img">'},
|
||||
{pattern: /\[强\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_80@2x.png" id="强" class="emoji_img">'},
|
||||
{pattern: /\[弱\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_81@2x.png" id="弱" class="emoji_img">'},
|
||||
{pattern: /\[握手\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_82@2x.png" id="握手" class="emoji_img">'},
|
||||
{pattern: /\[胜利\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_83@2x.png" id="胜利" class="emoji_img">'},
|
||||
{pattern: /\[抱拳\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_84@2x.png" id="抱拳" class="emoji_img">'},
|
||||
{pattern: /\[勾引\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_85@2x.png" id="勾引" class="emoji_img">'},
|
||||
{pattern: /\[拳头\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_86@2x.png" id="拳头" class="emoji_img">'},
|
||||
{pattern: /\[OK\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_90@2x.png" id="OK" class="emoji_img">'},
|
||||
{pattern: /\[合十\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Worship.png" id="合十" class="emoji_img">'},
|
||||
{pattern: /\[啤酒\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_58@2x.png" id="啤酒" class="emoji_img">'},
|
||||
{pattern: /\[咖啡]\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_61@2x.png" id="咖啡" class="emoji_img">'},
|
||||
{pattern: /\[蛋糕\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_69@2x.png" id="蛋糕" class="emoji_img">'},
|
||||
{pattern: /\[玫瑰\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_64@2x.png" id="玫 瑰" class="emoji_img">'},
|
||||
{pattern: /\[凋谢\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_65@2x.png" id="凋谢" class="emoji_img">'},
|
||||
{pattern: /\[菜刀\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_56@2x.png" id="菜刀" class="emoji_img">'},
|
||||
{pattern: /\[炸弹\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_71@2x.png" id="炸弹" class="emoji_img">'},
|
||||
{pattern: /\[便便\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_75@2x.png" id="便便" class="emoji_img">'},
|
||||
{pattern: /\[月亮\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_76@2x.png" id="月亮" class="emoji_img">'},
|
||||
{pattern: /\[太阳\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_77@2x.png" id="太阳" class="emoji_img">'},
|
||||
{pattern: /\[庆 祝\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Party.png" id="庆祝" class="emoji_img">'},
|
||||
{pattern: /\[礼物\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_78@2x.png" id="礼物" class="emoji_img">'},
|
||||
{pattern: /\[红包\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/2_09.png" id="红包" class="emoji_img">'},
|
||||
{pattern: /\[發\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/2_16.png" id="發" class="emoji_img">'},
|
||||
{pattern: /\[福\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/2_15.png" id="福" class="emoji_img">'},
|
||||
{pattern: /\[烟花\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Fireworks.png" id="烟花" class="emoji_img">'},
|
||||
{pattern: /\[爆竹\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/newemoji/Firecracker.png" id="爆竹" class="emoji_img">'},
|
||||
{pattern: /\[猪头\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_63@2x.png" id="猪头" class="emoji_img">'},
|
||||
{pattern: /\[跳跳\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_93@2x.png" id="跳跳" class="emoji_img">'},
|
||||
{pattern: /\[发抖\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_94@2x.png" id="发抖" class="emoji_img">'},
|
||||
{pattern: /\[转圈\]/g, replacement: '<img src="https://res.wx.qq.com/t/wx_fed/we-emoji/res/v1.2.8/assets/Expression/Expression_96@2x.png" id="转圈" class="emoji_img">'}
|
||||
];
|
||||
|
||||
// 循环遍历替换规则
|
||||
for (var i = 0; i < replacementRules.length; i++) {
|
||||
var rule = replacementRules[i];
|
||||
text= text.replace(rule.pattern, rule.replacement);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
// 生成各类标签的函数
|
||||
function messageBubble(message, side) {
|
||||
const messageBubbleTag = document.createElement('div');
|
||||
messageBubbleTag.className = `bubble bubble-${side}`;
|
||||
messageBubbleTag.innerHTML = replaceEmoji(message.text);
|
||||
return messageBubbleTag;
|
||||
}
|
||||
function displayNameBox(message) {
|
||||
const displayName = document.createElement('div');
|
||||
displayName.className = "displayname";
|
||||
displayName.innerHTML = message.displayname;
|
||||
return displayName;
|
||||
}
|
||||
function avatarBox(message) {
|
||||
const avatarTag = document.createElement('div');
|
||||
avatarTag.className = "avatar";
|
||||
avatarTag.innerHTML = `<img src="${message.avatar_path}" />`
|
||||
return avatarTag;
|
||||
}
|
||||
function messageImgBox(message) {
|
||||
const messageImgTag = document.createElement('div');
|
||||
messageImgTag.className = `chat-image`;
|
||||
messageImgTag.innerHTML = `<img src="${message.text}" onclick="showModal(this)"/>`;
|
||||
return messageImgTag;
|
||||
}
|
||||
function messageVideoBox(message) {
|
||||
const messageVideoTag = document.createElement('div');
|
||||
messageVideoTag.className = `chat-video`;
|
||||
messageVideoTag.innerHTML = `<video src="${message.text}" controls />`;
|
||||
return messageVideoTag;
|
||||
}
|
||||
function messageElementReferText(message, side) {
|
||||
const messageElementRefer = document.createElement('div');
|
||||
messageElementRefer.className = `chat-refer chat-refer-${side}`;
|
||||
messageElementRefer.innerHTML = replaceEmoji(message.refer_text);
|
||||
return messageElementRefer;
|
||||
}
|
||||
function messageVoiceToTextBubble(message, side) {
|
||||
const messageVoiceToTextTag = document.createElement('div');
|
||||
messageVoiceToTextTag.className = `bubble bubble-${side}`;
|
||||
messageVoiceToTextTag.innerHTML = message.voice_to_text;
|
||||
return messageVoiceToTextTag;
|
||||
}
|
||||
function messageAudioBox(message) {
|
||||
const messageAudioTag = document.createElement('div');
|
||||
messageAudioTag.className = `chat-audio`;
|
||||
messageAudioTag.innerHTML = `<audio src="${message.text}" controls></audio>`;
|
||||
return messageAudioTag;
|
||||
}
|
||||
function messageFileBox(message) {
|
||||
const messageFileTag = document.createElement('div');
|
||||
messageFileTag.className = `chat-file`;
|
||||
if (message.link !== ''){
|
||||
messageFileTag.innerHTML = `
|
||||
<a href="${message.link}" target="_blank"><span>${message.file_name}</span><img src="${message.text}"/></a>`
|
||||
}else{
|
||||
messageFileTag.innerHTML = `<div><span>文件已丢失</span><img src="${message.text}"/></div>`;
|
||||
}
|
||||
return messageFileTag;
|
||||
}
|
||||
|
||||
// 从数据列表中取出对应范围的元素并添加到容器中
|
||||
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 = `<span>${timestampToTime(message.timestamp)}</span>`;
|
||||
chatContainer.appendChild(newTimeMessage);
|
||||
console.log("增加时间元素", timestampToTime(message.timestamp));
|
||||
}
|
||||
}
|
||||
const messageElement = document.createElement('div'); // 下面那俩的合体
|
||||
const avatarTag = avatarBox(message); // 头像
|
||||
const messageContent = document.createElement('div'); // 除了avatar之外的所有
|
||||
const side = message.is_send ? "right" : "left";
|
||||
if (message.type == 1) {
|
||||
// displayname 和 bubble
|
||||
messageContent.className = `content-wrapper content-wrapper-${side}`;
|
||||
if (message.is_chatroom && !message.is_send) {
|
||||
messageContent.appendChild(displayNameBox(message));
|
||||
}
|
||||
messageContent.appendChild(messageBubble(message, side));
|
||||
|
||||
// 整合
|
||||
messageElement.className = `item item-${side}`;
|
||||
messageElement.appendChild(message.is_send ? messageContent : avatarTag);
|
||||
messageElement.appendChild(message.is_send ? avatarTag : messageContent);
|
||||
}
|
||||
else if (message.type == 0) {
|
||||
messageElement.className = "item item-center";
|
||||
messageElement.innerHTML = `<span>${message.text}</span>`;
|
||||
}
|
||||
else if (message.type == 3) {
|
||||
// displayname 和 img
|
||||
messageContent.className = `content-wrapper content-wrapper-${side}`;
|
||||
if (message.is_chatroom && !message.is_send) {
|
||||
messageContent.appendChild(displayNameBox(message));
|
||||
}
|
||||
messageContent.appendChild(messageImgBox(message));
|
||||
|
||||
// 整合
|
||||
messageElement.className = `item item-${side}`;
|
||||
messageElement.appendChild(message.is_send ? messageContent : avatarTag);
|
||||
messageElement.appendChild(message.is_send ? avatarTag : messageContent);
|
||||
}
|
||||
else if (message.type == 43) {
|
||||
// displayname 和 video
|
||||
messageContent.className = `content-wrapper content-wrapper-${side}`;
|
||||
if (message.is_chatroom && !message.is_send) {
|
||||
messageContent.appendChild(displayNameBox(message));
|
||||
}
|
||||
messageContent.appendChild(messageVideoBox(message));
|
||||
|
||||
// 整合
|
||||
messageElement.className = `item item-${side}`;
|
||||
messageElement.appendChild(message.is_send ? messageContent : avatarTag);
|
||||
messageElement.appendChild(message.is_send ? avatarTag : messageContent);
|
||||
}
|
||||
else if (message.type == 49) {
|
||||
if (message.sub_type == 57) {
|
||||
// displayname 和 bubble 和 refer
|
||||
messageContent.className = `content-wrapper content-wrapper-${side}`;
|
||||
if (message.is_chatroom && !message.is_send) {
|
||||
messageContent.appendChild(displayNameBox(message));
|
||||
}
|
||||
messageContent.appendChild(messageBubble(message, side));
|
||||
if (message.refer_text) {
|
||||
messageContent.appendChild(messageElementReferText(message, side));
|
||||
}
|
||||
|
||||
// 整合
|
||||
messageElement.className = `item item-${side}`;
|
||||
messageElement.appendChild(message.is_send ? messageContent : avatarTag);
|
||||
messageElement.appendChild(message.is_send ? avatarTag : messageContent);
|
||||
}
|
||||
if (message.sub_type == 6) {
|
||||
// displayname 和 file
|
||||
messageContent.className = `content-wrapper content-wrapper-${side}`;
|
||||
if (message.is_chatroom && !message.is_send) {
|
||||
messageContent.appendChild(displayNameBox(message));
|
||||
}
|
||||
messageContent.appendChild(messageFileBox(message));
|
||||
|
||||
// 整合
|
||||
messageElement.className = `item item-${side}`;
|
||||
messageElement.appendChild(message.is_send ? messageContent : avatarTag);
|
||||
messageElement.appendChild(message.is_send ? avatarTag : messageContent);
|
||||
}
|
||||
}
|
||||
else if (message.type == 34) {
|
||||
// displayname 和 转的文字 和 audio
|
||||
messageContent.className = `content-wrapper content-wrapper-${side}`;
|
||||
if (message.is_chatroom && !message.is_send) {
|
||||
messageContent.appendChild(displayNameBox(message));
|
||||
}
|
||||
if (message.voice_to_text) {
|
||||
messageContent.appendChild(messageVoiceToTextBubble(message, side));
|
||||
}
|
||||
messageContent.appendChild(messageAudioBox(message));
|
||||
|
||||
// 整合
|
||||
messageElement.className = `item item-${side}`;
|
||||
messageElement.appendChild(message.is_send ? messageContent : avatarTag);
|
||||
messageElement.appendChild(message.is_send ? avatarTag : messageContent);
|
||||
}
|
||||
chatContainer.appendChild(messageElement);
|
||||
}
|
||||
document.querySelector("#chat-container").scrollTop = lastScrollTop;
|
||||
updatePaginationInfo();
|
||||
refreshMediaListener();
|
||||
}
|
||||
|
||||
function prevPage() {
|
||||
if (currentPage > 1) {
|
||||
currentPage--;
|
||||
renderPage(currentPage);
|
||||
}
|
||||
}
|
||||
|
||||
function nextPage() {
|
||||
const totalPages = Math.ceil(chatMessages.length / itemsPerPage);
|
||||
if (currentPage < totalPages) {
|
||||
currentPage++;
|
||||
renderPage(currentPage);
|
||||
}
|
||||
}
|
||||
function updatePaginationInfo() {
|
||||
const totalPages = Math.ceil(chatMessages.length / itemsPerPage);
|
||||
const paginationInfo = document.getElementById('paginationInfo');
|
||||
paginationInfo.textContent = `共 ${totalPages} 页,当前第 ${currentPage} 页`;
|
||||
}
|
||||
function gotoPage() {
|
||||
const totalPages = Math.ceil(chatMessages.length / itemsPerPage);
|
||||
const inputElement = document.getElementById('gotoPageInput');
|
||||
const targetPage = parseInt(inputElement.value);
|
||||
|
||||
if (targetPage >= 1 && targetPage <= totalPages) {
|
||||
currentPage = targetPage;
|
||||
renderPage(currentPage);
|
||||
} else {
|
||||
alert('请输入有效的页码');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function checkScroll() {
|
||||
var chatContainer = document.getElementById("chat-container");
|
||||
|
||||
// 检查滚动条是否滑到底部
|
||||
if (chatContainer.scrollHeight - chatContainer.scrollTop - 10 <= chatContainer.clientHeight) {
|
||||
// 如果滚动条在底部
|
||||
if (!reachedBottom) {
|
||||
// 设置标记并返回
|
||||
reachedBottom = true;
|
||||
lastScrollTop = chatContainer.scrollTop;
|
||||
}
|
||||
if (reachedBottom) {
|
||||
nextPage();
|
||||
}
|
||||
}
|
||||
}
|
||||
// 初始化页面
|
||||
renderPage(currentPage);
|
||||
|
||||
function refreshMediaListener() {
|
||||
const audioTags = document.querySelectorAll('audio');
|
||||
const videoTags = document.querySelectorAll('video');
|
||||
|
||||
audioTags.forEach(audio => {
|
||||
audio.addEventListener('play', function () {
|
||||
pauseOtherMedia(audio);
|
||||
});
|
||||
});
|
||||
videoTags.forEach(video => {
|
||||
video.addEventListener('play', function () {
|
||||
pauseOtherMedia(video);
|
||||
});
|
||||
});
|
||||
|
||||
function pauseOtherMedia(currentMedia) {
|
||||
const audioTags = document.querySelectorAll('audio');
|
||||
const videoTags = document.querySelectorAll('video');
|
||||
audioTags.forEach(media => {
|
||||
if (media !== currentMedia && !media.paused) {
|
||||
media.pause();
|
||||
}
|
||||
});
|
||||
videoTags.forEach(media => {
|
||||
if (media !== currentMedia && !media.paused) {
|
||||
media.pause();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
refreshMediaListener();
|
||||
</script>
|
||||
|
||||
<script>
|
||||
function showModal(image) {
|
||||
var modal = document.getElementById("modal");
|
||||
var modalImage = document.getElementById("modal-image");
|
||||
modal.style.display = "block";
|
||||
modalImage.src = image.src;
|
||||
console.log(image.src);
|
||||
}
|
||||
|
||||
function hideModal() {
|
||||
var modal = document.getElementById("modal");
|
||||
modal.style.display = "none";
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,394 +0,0 @@
|
||||
{
|
||||
"3.2.1.154": [
|
||||
328121948,
|
||||
328122328,
|
||||
328123056,
|
||||
328121976,
|
||||
328123020,
|
||||
0
|
||||
],
|
||||
"3.3.0.115": [
|
||||
31323364,
|
||||
31323744,
|
||||
31324472,
|
||||
31323392,
|
||||
31324436,
|
||||
0
|
||||
],
|
||||
"3.3.0.84": [
|
||||
31315212,
|
||||
31315592,
|
||||
31316320,
|
||||
31315240,
|
||||
31316284,
|
||||
0
|
||||
],
|
||||
"3.3.0.93": [
|
||||
31323364,
|
||||
31323744,
|
||||
31324472,
|
||||
31323392,
|
||||
31324436,
|
||||
0
|
||||
],
|
||||
"3.3.5.34": [
|
||||
30603028,
|
||||
30603408,
|
||||
30604120,
|
||||
30603056,
|
||||
30604100,
|
||||
0
|
||||
],
|
||||
"3.3.5.42": [
|
||||
30603012,
|
||||
30603392,
|
||||
30604120,
|
||||
30603040,
|
||||
30604084,
|
||||
0
|
||||
],
|
||||
"3.3.5.46": [
|
||||
30578372,
|
||||
30578752,
|
||||
30579480,
|
||||
30578400,
|
||||
30579444,
|
||||
0
|
||||
],
|
||||
"3.4.0.37": [
|
||||
31608116,
|
||||
31608496,
|
||||
31609224,
|
||||
31608144,
|
||||
31609188,
|
||||
0
|
||||
],
|
||||
"3.4.0.38": [
|
||||
31604044,
|
||||
31604424,
|
||||
31605152,
|
||||
31604072,
|
||||
31605116,
|
||||
0
|
||||
],
|
||||
"3.4.0.50": [
|
||||
31688500,
|
||||
31688880,
|
||||
31689608,
|
||||
31688528,
|
||||
31689572,
|
||||
0
|
||||
],
|
||||
"3.4.0.54": [
|
||||
31700852,
|
||||
31701248,
|
||||
31700920,
|
||||
31700880,
|
||||
31701924,
|
||||
0
|
||||
],
|
||||
"3.4.5.27": [
|
||||
32133788,
|
||||
32134168,
|
||||
32134896,
|
||||
32133816,
|
||||
32134860,
|
||||
0
|
||||
],
|
||||
"3.4.5.45": [
|
||||
32147012,
|
||||
32147392,
|
||||
32147064,
|
||||
32147040,
|
||||
32148084,
|
||||
0
|
||||
],
|
||||
"3.5.0.20": [
|
||||
35494484,
|
||||
35494864,
|
||||
35494536,
|
||||
35494512,
|
||||
35495556,
|
||||
0
|
||||
],
|
||||
"3.5.0.29": [
|
||||
35507980,
|
||||
35508360,
|
||||
35508032,
|
||||
35508008,
|
||||
35509052,
|
||||
0
|
||||
],
|
||||
"3.5.0.33": [
|
||||
35512140,
|
||||
35512520,
|
||||
35512192,
|
||||
35512168,
|
||||
35513212,
|
||||
0
|
||||
],
|
||||
"3.5.0.39": [
|
||||
35516236,
|
||||
35516616,
|
||||
35516288,
|
||||
35516264,
|
||||
35517308,
|
||||
0
|
||||
],
|
||||
"3.5.0.42": [
|
||||
35512140,
|
||||
35512520,
|
||||
35512192,
|
||||
35512168,
|
||||
35513212,
|
||||
0
|
||||
],
|
||||
"3.5.0.44": [
|
||||
35510836,
|
||||
35511216,
|
||||
35510896,
|
||||
35510864,
|
||||
35511908,
|
||||
0
|
||||
],
|
||||
"3.5.0.46": [
|
||||
35506740,
|
||||
35507120,
|
||||
35506800,
|
||||
35506768,
|
||||
35507812,
|
||||
0
|
||||
],
|
||||
"3.6.0.18": [
|
||||
35842996,
|
||||
35843376,
|
||||
35843048,
|
||||
35843024,
|
||||
35844068,
|
||||
0
|
||||
],
|
||||
"3.6.5.7": [
|
||||
35864356,
|
||||
35864736,
|
||||
35864408,
|
||||
35864384,
|
||||
35865428,
|
||||
0
|
||||
],
|
||||
"3.6.5.16": [
|
||||
35909428,
|
||||
35909808,
|
||||
35909480,
|
||||
35909456,
|
||||
35910500,
|
||||
0
|
||||
],
|
||||
"3.7.0.26": [
|
||||
37105908,
|
||||
37106288,
|
||||
37105960,
|
||||
37105936,
|
||||
37106980,
|
||||
0
|
||||
],
|
||||
"3.7.0.29": [
|
||||
37105908,
|
||||
37106288,
|
||||
37105960,
|
||||
37105936,
|
||||
37106980,
|
||||
0
|
||||
],
|
||||
"3.7.0.30": [
|
||||
37118196,
|
||||
37118576,
|
||||
37118248,
|
||||
37118224,
|
||||
37119268,
|
||||
0
|
||||
],
|
||||
"3.7.5.11": [
|
||||
37883280,
|
||||
37884088,
|
||||
37883136,
|
||||
37883008,
|
||||
37884052,
|
||||
0
|
||||
],
|
||||
"3.7.5.23": [
|
||||
37895736,
|
||||
37896544,
|
||||
37895592,
|
||||
37883008,
|
||||
37896508,
|
||||
0
|
||||
],
|
||||
"3.7.5.27": [
|
||||
37895736,
|
||||
37896544,
|
||||
37895592,
|
||||
37895464,
|
||||
37896508,
|
||||
0
|
||||
],
|
||||
"3.7.5.31": [
|
||||
37903928,
|
||||
37904736,
|
||||
37903784,
|
||||
37903656,
|
||||
37904700,
|
||||
0
|
||||
],
|
||||
"3.7.6.24": [
|
||||
38978840,
|
||||
38979648,
|
||||
38978696,
|
||||
38978604,
|
||||
38979612,
|
||||
0
|
||||
],
|
||||
"3.7.6.29": [
|
||||
38986376,
|
||||
38987184,
|
||||
38986232,
|
||||
38986104,
|
||||
38987148,
|
||||
0
|
||||
],
|
||||
"3.7.6.44": [
|
||||
39016520,
|
||||
39017328,
|
||||
39016376,
|
||||
38986104,
|
||||
39017292,
|
||||
0
|
||||
],
|
||||
"3.8.0.31": [
|
||||
46064088,
|
||||
46064912,
|
||||
46063944,
|
||||
38986104,
|
||||
46064876,
|
||||
0
|
||||
],
|
||||
"3.8.0.33": [
|
||||
46059992,
|
||||
46060816,
|
||||
46059848,
|
||||
38986104,
|
||||
46060780,
|
||||
0
|
||||
],
|
||||
"3.8.0.41": [
|
||||
46064024,
|
||||
46064848,
|
||||
46063880,
|
||||
38986104,
|
||||
46064812,
|
||||
0
|
||||
],
|
||||
"3.8.1.26": [
|
||||
46409448,
|
||||
46410272,
|
||||
46409304,
|
||||
38986104,
|
||||
46410236,
|
||||
0
|
||||
],
|
||||
"3.9.0.28": [
|
||||
48418376,
|
||||
48419280,
|
||||
48418232,
|
||||
38986104,
|
||||
48419244,
|
||||
0
|
||||
],
|
||||
"3.9.2.23": [
|
||||
50320784,
|
||||
50321712,
|
||||
50320640,
|
||||
38986104,
|
||||
50321676,
|
||||
50592864
|
||||
],
|
||||
"3.9.2.26": [
|
||||
50329040,
|
||||
50329968,
|
||||
50328896,
|
||||
38986104,
|
||||
50329932,
|
||||
0
|
||||
],
|
||||
"3.9.5.81": [
|
||||
61650872,
|
||||
61652208,
|
||||
61650680,
|
||||
0,
|
||||
61652144,
|
||||
0
|
||||
],
|
||||
"3.9.5.91": [
|
||||
61654904,
|
||||
61656240,
|
||||
61654712,
|
||||
38986104,
|
||||
61656176,
|
||||
61677112
|
||||
],
|
||||
"3.9.6.19": [
|
||||
61997688,
|
||||
61997464,
|
||||
61997496,
|
||||
38986104,
|
||||
61998960,
|
||||
0
|
||||
],
|
||||
"3.9.6.33": [
|
||||
62030600,
|
||||
62031936,
|
||||
62030408,
|
||||
0,
|
||||
62031872,
|
||||
0
|
||||
],
|
||||
"3.9.7.15": [
|
||||
63482696,
|
||||
63484032,
|
||||
63482504,
|
||||
0,
|
||||
63483968,
|
||||
0
|
||||
],
|
||||
"3.9.7.25": [
|
||||
63482760,
|
||||
63484096,
|
||||
63482568,
|
||||
0,
|
||||
63484032,
|
||||
0
|
||||
],
|
||||
"3.9.7.29": [
|
||||
63486984,
|
||||
63488320,
|
||||
63486792,
|
||||
0,
|
||||
63488256,
|
||||
63488352
|
||||
],
|
||||
"3.9.8.15": [
|
||||
64996632,
|
||||
64997968,
|
||||
64996440,
|
||||
0,
|
||||
64997904,
|
||||
65011632
|
||||
],
|
||||
"3.9.8.25": [
|
||||
65000920,
|
||||
0,
|
||||
65000728,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
}
|
@ -267,10 +267,10 @@ class MyThread(QThread):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
file_path = './app/resources/version_list.json'
|
||||
file_path = './app/resources/data/version_list.json'
|
||||
if not os.path.exists(file_path):
|
||||
resource_dir = getattr(sys, '_MEIPASS', os.path.abspath(os.path.dirname(__file__)))
|
||||
file_path = os.path.join(resource_dir, 'app', 'resources', 'version_list.json')
|
||||
file_path = os.path.join(resource_dir, 'app', 'resources', 'data','version_list.json')
|
||||
with open(file_path, "r", encoding="utf-8") as f:
|
||||
VERSION_LIST = json.loads(f.read())
|
||||
try:
|
||||
|
@ -284,7 +284,7 @@ def get_emoji_url(xml_string, thumb=True) -> str:
|
||||
return url
|
||||
except:
|
||||
logger.error(traceback.format_exc())
|
||||
output_path = os.path.join(output_path, "404.png")
|
||||
output_path = os.path.join("./emoji/404.png")
|
||||
return output_path
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user