Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/aaaz' into dev_zsk
Browse files Browse the repository at this point in the history
# Conflicts:
#	app/DataBase/output_pc.py
#	app/util/path.py
  • Loading branch information
LC044 committed Nov 28, 2023
2 parents ab2d805 + 6412cb2 commit 652ffd7
Show file tree
Hide file tree
Showing 5 changed files with 181 additions and 3 deletions.
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/custom.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
name: Custom issue template
about: Describe this issue template's purpose here.
title: ''
labels: ''
assignees: ''

---


20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
114 changes: 111 additions & 3 deletions app/DataBase/output_pc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from . import msg
from ..person_pc import MePC

from ..DataBase import hard_link
from ..util import get_abs_path
if not os.path.exists('./data/聊天记录'):
os.mkdir('./data/聊天记录')

Expand Down Expand Up @@ -544,6 +546,12 @@ def to_html_(self):
user-select:none;
}
.chat-image img{
margin-right: 18px;
margin-left: 18px;
max-width: 300px;
max-height: auto;
}
.avatar img{
width: 42px;
height: 42px;
Expand Down Expand Up @@ -600,6 +608,56 @@ def to_html_(self):
-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;
}
</style>
</head>
<body>
Expand Down Expand Up @@ -629,13 +687,16 @@ def to_html_(self):
</div>
<div></div>
<div>
<div class="pagination-container">
<div class="button-row">
<button onclick="prevPage()">上一页</button>
<div id = "paginationInfo"></div>
<button onclick="nextPage()">下一页</button>
<div></div>
</div>
<div class="jump-row">
<input type="number" id="gotoPageInput" placeholder="跳转到第几页">
<button onclick="gotoPage()">跳转</button>
</div>
<div id="paginationInfo"></div>
</div>
<script>
const chatContainer = document.getElementById('chat-container');
Expand All @@ -657,6 +718,11 @@ def to_html_(self):
avatar = 'myhead.png' if is_send else 'tahead.png'
timestamp = message[5]
self.progressSignal.emit(index)

if type_ == 1:
str_content = str_content.replace('"', '\\"').replace('{', '\\{').replace('}', '\\}').replace('\n',
'\\n').replace(
"'", "\\'")
str_content = escape_js_and_html(str_content)
if type_ == 1:
if self.is_5_min(timestamp):
Expand All @@ -666,6 +732,28 @@ def to_html_(self):
f.write(
f'''{{ type:{type_}, text: '{str_content}',is_send:{is_send},avatar_path:'{avatar}'}},'''
)
elif type_ == 3:
import re
pattern1 = r'<msg><img length="\d+" hdlength="0" /><commenturl></commenturl></msg>'
pattern2 = r'<msg><img /></msg>'
match = re.search(pattern1, str_content)
if match:
continue
match = re.search(pattern2, str_content)
if match:
continue

image_path = hard_link.get_image(content=str_content, thumb=False)
image_path = get_abs_path(image_path)
image_path = image_path.replace('\\', '/')
# print(f"tohtml:---{image_path}")
if self.is_5_min(timestamp):
f.write(
f'''{{ type:0, text: '{str_time}',is_send:0,avatar_path:''}},'''
)
f.write(
f'''{{ type:{type_}, text: '{image_path}',is_send:{is_send},avatar_path:'{avatar}'}},'''
)
html_end = '''
];
function renderMessages(messages) {
Expand All @@ -685,6 +773,16 @@ def to_html_(self):
messageElement.className = "item item-center";
messageElement.innerHTML = `<span>${message.text}</span>`
}
else if (message.type == 3){
if (message.is_send == 1){
messageElement.className = "item item-right";
messageElement.innerHTML = `<div class='chat-image'><img src="${message.text}" /></div><div class='avatar'><img src="${message.avatar_path}" /></div>`
}
else if(message.is_send==0){
messageElement.className = "item item-left";
messageElement.innerHTML = `<div class='avatar'><img src="${message.avatar_path}" /></div><div class='chat-image'><img src="${message.text}" /></div>`
}
}
chatContainer.appendChild(messageElement);
}
}
Expand Down Expand Up @@ -719,6 +817,16 @@ def to_html_(self):
messageElement.className = "item item-center";
messageElement.innerHTML = `<span>${message.text}</span>`
}
else if (message.type == 3){
if (message.is_send == 1){
messageElement.className = "item item-right";
messageElement.innerHTML = `<div class='chat-image'><img src="${message.text}" /></div><div class='avatar'><img src="${message.avatar_path}" /></div>`
}
else if(message.is_send==0){
messageElement.className = "item item-left";
messageElement.innerHTML = `<div class='avatar'><img src="${message.avatar_path}" /></div><div class='chat-image'><img src="${message.text}" /></div>`
}
}
chatContainer.appendChild(messageElement);
}
updatePaginationInfo();
Expand Down
2 changes: 2 additions & 0 deletions app/util/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ def get_abs_path(path):
# print(path, os.path.join(MePC().wx_dir, path), MePC().wx_dir)
output_path = dat2pic.decode_dat(os.path.join(MePC().wx_dir, path), './data/image')

base_path = os.getcwd() + "/data/image"
output_path = dat2pic.decode_dat(os.path.join(MePC().wx_dir, path), base_path) #'./data/image')
return output_path
else:
return ':/icons/icons/404.png'

0 comments on commit 652ffd7

Please sign in to comment.