常规更新
This commit is contained in:
parent
2f6ae2b404
commit
5532839f51
@ -0,0 +1,3 @@
|
|||||||
|
'''
|
||||||
|
文档生成功能暂无开发计划。
|
||||||
|
'''
|
||||||
@ -1,5 +1,8 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: UTF-8 -*-
|
# -*- coding: UTF-8 -*-
|
||||||
|
'''
|
||||||
|
邮件发送功能开发流程已中断,无实际利用场景。
|
||||||
|
'''
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
import smtplib
|
import smtplib
|
||||||
|
|||||||
@ -27,7 +27,7 @@ e_hour: 4 # 程序运行时间间隔
|
|||||||
time_mode: 1
|
time_mode: 1
|
||||||
# 0:定时运行模式,仅在指定时间运行(参照Core.py中设置)
|
# 0:定时运行模式,仅在指定时间运行(参照Core.py中设置)
|
||||||
# 1:启用循环,一定间隔时间后运行
|
# 1:启用循环,一定间隔时间后运行
|
||||||
mode: [1, 2, 3] # 运行模式,可多选
|
mode: [0, 1, 2, 3] # 运行模式,可多选
|
||||||
# 0:启用RSS抓取模式
|
# 0:启用RSS抓取模式
|
||||||
# 1:启用搜狗-微信公众号文章监测
|
# 1:启用搜狗-微信公众号文章监测
|
||||||
# 2:启用github项目监测
|
# 2:启用github项目监测
|
||||||
|
|||||||
@ -4,12 +4,18 @@ translate: False # 是否开启翻译
|
|||||||
|
|
||||||
# 监控列表
|
# 监控列表
|
||||||
tool_list: # 监控已创建的仓库是否更新
|
tool_list: # 监控已创建的仓库是否更新
|
||||||
- BeichenDream/Godzilla
|
|
||||||
- wy876/POC
|
|
||||||
|
|
||||||
keyword_list: # 监控关键词
|
keyword_list: # 监控关键词
|
||||||
- sql注入
|
- 未授权
|
||||||
- cnvd
|
- POC
|
||||||
|
- RCE
|
||||||
|
- 反序列化
|
||||||
|
- webshell
|
||||||
|
- CVE-2026
|
||||||
|
- 内网渗透
|
||||||
|
- 漏洞检测
|
||||||
|
- 钓鱼
|
||||||
|
|
||||||
user_list: # 监控用户
|
user_list: # 监控用户
|
||||||
|
|
||||||
|
|||||||
94
install.sh
Normal file
94
install.sh
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# 获取当前目录
|
||||||
|
BASE_DIR=$(cd "$(dirname "$0")"; pwd)
|
||||||
|
USER_NAME=$(whoami)
|
||||||
|
|
||||||
|
echo "项目路径: $BASE_DIR"
|
||||||
|
|
||||||
|
# ========= 自动检测 Python =========
|
||||||
|
detect_python() {
|
||||||
|
if command -v python >/dev/null 2>&1; then
|
||||||
|
PY=python
|
||||||
|
elif command -v python3 >/dev/null 2>&1; then
|
||||||
|
PY=python3
|
||||||
|
else
|
||||||
|
echo "❌ 未检测到 Python,请先安装 Python 3.6+"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 获取版本号
|
||||||
|
VERSION=$($PY -c 'import sys; print(".".join(map(str, sys.version_info[:3])))')
|
||||||
|
|
||||||
|
echo "检测到 Python: $PY ($VERSION)"
|
||||||
|
|
||||||
|
# 校验版本 >= 3.6
|
||||||
|
MAJOR=$(echo $VERSION | cut -d. -f1)
|
||||||
|
MINOR=$(echo $VERSION | cut -d. -f2)
|
||||||
|
|
||||||
|
if [ "$MAJOR" -lt 3 ] || { [ "$MAJOR" -eq 3 ] && [ "$MINOR" -lt 6 ]; }; then
|
||||||
|
echo "❌ Python 版本过低(需要 >= 3.6)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
PYTHON_CMD=$PY
|
||||||
|
}
|
||||||
|
|
||||||
|
detect_python
|
||||||
|
|
||||||
|
# ========= 创建 PyBot 服务 =========
|
||||||
|
sudo bash -c "cat > /etc/systemd/system/PyBot.service" <<EOF
|
||||||
|
[Unit]
|
||||||
|
Description=PyBot Core Service
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=$USER_NAME
|
||||||
|
WorkingDirectory=$BASE_DIR
|
||||||
|
ExecStart=$PYTHON_CMD $BASE_DIR/core.py
|
||||||
|
Restart=always
|
||||||
|
RestartSec=3
|
||||||
|
StartLimitInterval=0
|
||||||
|
Environment=PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# ========= 创建 PyBot_Web 服务 =========
|
||||||
|
sudo bash -c "cat > /etc/systemd/system/PyBot_Web.service" <<EOF
|
||||||
|
[Unit]
|
||||||
|
Description=PyBot Web Service
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User=$USER_NAME
|
||||||
|
WorkingDirectory=$BASE_DIR
|
||||||
|
ExecStart=$PYTHON_CMD $BASE_DIR/web/app.py
|
||||||
|
Restart=always
|
||||||
|
RestartSec=3
|
||||||
|
StartLimitInterval=0
|
||||||
|
Environment=PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# ========= 重新加载 =========
|
||||||
|
sudo systemctl daemon-reexec
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
|
||||||
|
# ========= 启用 + 启动 =========
|
||||||
|
sudo systemctl enable PyBot
|
||||||
|
sudo systemctl enable PyBot_Web
|
||||||
|
|
||||||
|
sudo systemctl restart PyBot
|
||||||
|
sudo systemctl restart PyBot_Web
|
||||||
|
|
||||||
|
echo "===================================="
|
||||||
|
echo "✅ 服务已创建并启动"
|
||||||
|
echo "PyBot → core.py"
|
||||||
|
echo "PyBot_Web → web/app.py"
|
||||||
|
echo "===================================="
|
||||||
@ -6,5 +6,4 @@ requests
|
|||||||
python-dateutil
|
python-dateutil
|
||||||
loguru
|
loguru
|
||||||
beautifulsoup4
|
beautifulsoup4
|
||||||
|
|
||||||
feedparser
|
feedparser
|
||||||
13
test.py
13
test.py
@ -1,13 +0,0 @@
|
|||||||
import feedparser
|
|
||||||
|
|
||||||
feed_url = "https://security.tencent.com/index.php/feed/blog/0"
|
|
||||||
feed = feedparser.parse(feed_url)
|
|
||||||
|
|
||||||
for entry in feed.entries:
|
|
||||||
print(entry.title)
|
|
||||||
print(entry.link)
|
|
||||||
print(entry.id)
|
|
||||||
print(entry.summary)
|
|
||||||
print(entry.id)
|
|
||||||
# 打印所有属性,找出正确的日期字段名
|
|
||||||
# print(entry.keys())
|
|
||||||
@ -38,12 +38,12 @@ def replace_content(content):
|
|||||||
content = content.replace(r"e:\Self-Tool-Code\PyBot", '.') # 修改: 使用原始字符串避免转义问题
|
content = content.replace(r"e:\Self-Tool-Code\PyBot", '.') # 修改: 使用原始字符串避免转义问题
|
||||||
return content
|
return content
|
||||||
|
|
||||||
def get_records(content, num_records=20, delimiter='-'*40):
|
def get_records(content, num_records=50, delimiter='-'*40):
|
||||||
records = content.split(delimiter)
|
records = content.split(delimiter)
|
||||||
selected_records = records[:num_records]
|
selected_records = records[:num_records]
|
||||||
return delimiter.join(selected_records)
|
return delimiter.join(selected_records)
|
||||||
|
|
||||||
def read_last_lines(file_path, num_lines=100):
|
def read_last_lines(file_path, num_lines=200):
|
||||||
with open(file_path, 'r', encoding='utf-8') as file:
|
with open(file_path, 'r', encoding='utf-8') as file:
|
||||||
return deque(file, maxlen=num_lines)
|
return deque(file, maxlen=num_lines)
|
||||||
|
|
||||||
@ -111,4 +111,4 @@ def get_wx_news():
|
|||||||
return jsonify({'content': content}), status_code
|
return jsonify({'content': content}), status_code
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=True, port=666) # 在生产环境中应设置为 False
|
app.run(debug=False, port=9801) # 在生产环境中应设置为 False
|
||||||
@ -10,108 +10,221 @@
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
font-family: Arial, sans-serif;
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
margin: 10px; /* 减少边距 */
|
margin: 0;
|
||||||
|
padding: 20px;
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
line-height: 1.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.layui-container {
|
||||||
|
max-width: 1200px;
|
||||||
|
margin: 0 auto;
|
||||||
|
background: white;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
color: #333;
|
color: #333;
|
||||||
font-size: 1.5em; /* 适当减小标题字体 */
|
font-size: 1.8em;
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
border-bottom: 2px solid #009688;
|
||||||
|
padding-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#markdown-content {
|
#markdown-content {
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
font-size: 0.9em; /* 减小内容字体 */
|
font-size: 1em;
|
||||||
|
padding: 15px;
|
||||||
|
background-color: #fafafa;
|
||||||
|
border-radius: 4px;
|
||||||
|
min-height: 400px;
|
||||||
}
|
}
|
||||||
/* 返回顶部按钮样式 */
|
|
||||||
#back-to-top {
|
/* 按钮容器样式优化 */
|
||||||
display: none;
|
#button-container {
|
||||||
position: fixed;
|
display: flex;
|
||||||
bottom: 10px; /* 调整位置 */
|
justify-content: center;
|
||||||
right: 10px; /* 调整位置 */
|
flex-wrap: wrap;
|
||||||
z-index: 99;
|
gap: 10px;
|
||||||
font-size: 16px; /* 减小字体 */
|
margin: 15px 0;
|
||||||
border: none;
|
}
|
||||||
outline: none;
|
|
||||||
background-color: #555;
|
#button-container .layui-btn {
|
||||||
color: white;
|
margin: 5px;
|
||||||
cursor: pointer;
|
transition: all 0.3s ease;
|
||||||
padding: 10px; /* 减小内边距 */
|
min-width: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 不同类型的按钮使用不同颜色 */
|
||||||
|
#sec-news-btn { background-color: #FF5722; }
|
||||||
|
#tech-passage-btn { background-color: #2196F3; }
|
||||||
|
#baidu-news-btn { background-color: #2F4F4F; }
|
||||||
|
#github-news-btn { background-color: #333; }
|
||||||
|
#wx-news-btn { background-color: #07C160; }
|
||||||
|
|
||||||
|
/* 按钮悬停效果 */
|
||||||
|
#button-container .layui-btn:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 折叠面板样式优化 */
|
||||||
|
.layui-colla-item {
|
||||||
|
margin-bottom: 15px;
|
||||||
|
border-radius: 4px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.layui-colla-title {
|
||||||
|
background-color: #f2f2f2;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 提示文字样式 */
|
||||||
|
.info-text {
|
||||||
|
text-align: center;
|
||||||
|
color: #666;
|
||||||
|
font-size: 0.9em;
|
||||||
|
margin: 10px 0 20px;
|
||||||
|
padding: 10px;
|
||||||
|
background-color: #f0f8ff;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 返回顶部按钮样式 - 已优化 */
|
||||||
|
#back-to-top {
|
||||||
|
display: none; /* 初始隐藏,滚动后显示 */
|
||||||
|
position: fixed;
|
||||||
|
bottom: 20px;
|
||||||
|
right: 20px;
|
||||||
|
z-index: 1000;
|
||||||
|
font-size: 14px;
|
||||||
|
border: none;
|
||||||
|
outline: none;
|
||||||
|
background-color: #009688; /* 使用layui主题色 */
|
||||||
|
color: white;
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 12px 15px;
|
||||||
|
border-radius: 50%;
|
||||||
|
box-shadow: 0 2px 10px rgba(0,0,0,0.3);
|
||||||
|
transition: background-color 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
#back-to-top:hover {
|
#back-to-top:hover {
|
||||||
background-color: #777;
|
background-color: #007a6e;
|
||||||
|
transform: scale(1.1); /* 悬停放大效果 */
|
||||||
}
|
}
|
||||||
|
|
||||||
#markdown-content a {
|
#markdown-content a {
|
||||||
color: blue;
|
color: #009688;
|
||||||
text-decoration: none; /* 可选:去掉下划线 */
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
#markdown-content a:hover {
|
#markdown-content a:hover {
|
||||||
text-decoration: underline; /* 可选:鼠标悬停时显示下划线 */
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 错误消息样式 */
|
||||||
|
.error-message {
|
||||||
|
text-align: center;
|
||||||
|
padding: 40px;
|
||||||
|
color: #ff6b6b;
|
||||||
|
font-size: 1.1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 加载动画样式 */
|
||||||
|
.loading {
|
||||||
|
text-align: center;
|
||||||
|
padding: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
/* 移动端样式调整 */
|
/* 移动端样式调整 */
|
||||||
@media only screen and (max-width: 600px) {
|
@media only screen and (max-width: 600px) {
|
||||||
body {
|
body {
|
||||||
margin: 5px;
|
margin: 5px;
|
||||||
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.layui-container {
|
||||||
|
padding: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 1.2em;
|
font-size: 1.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#markdown-content {
|
#markdown-content {
|
||||||
font-size: 0.8em;
|
font-size: 0.9em;
|
||||||
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#back-to-top {
|
#back-to-top {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
padding: 8px;
|
padding: 10px;
|
||||||
|
bottom: 15px;
|
||||||
|
right: 15px;
|
||||||
}
|
}
|
||||||
#markdown-content a {
|
|
||||||
color: blue;
|
|
||||||
text-decoration: none; /* 可选:去掉下划线 */
|
|
||||||
}
|
|
||||||
#markdown-content a:hover {
|
|
||||||
text-decoration: underline; /* 可选:鼠标悬停时显示下划线 */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 按钮样式调整 */
|
/* 按钮样式调整 */
|
||||||
#button-container {
|
#button-container {
|
||||||
flex-direction: column; /* 换行显示按钮 */
|
flex-direction: column; /* 换行显示按钮 */
|
||||||
align-items: center; /* 按钮居中对齐 */
|
align-items: center; /* 按钮居中对齐 */
|
||||||
}
|
}
|
||||||
|
|
||||||
#button-container .layui-btn {
|
#button-container .layui-btn {
|
||||||
margin: 5px 0; /* 增加按钮间距 */
|
margin: 8px 0; /* 增加按钮间距 */
|
||||||
width: 90%; /* 调整按钮宽度 */
|
width: 95%; /* 调整按钮宽度 */
|
||||||
max-width: 300px; /* 设置最大宽度 */
|
max-width: 300px; /* 设置最大宽度 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 平滑滚动 */
|
||||||
|
html {
|
||||||
|
scroll-behavior: smooth;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="layui-container">
|
<div class="layui-container">
|
||||||
<center><h1 class="layui-title" id="page-title">历史推送读取</h1><br>
|
<h1 class="layui-title" id="page-title">📰 资讯推送中心</h1>
|
||||||
|
|
||||||
|
<!-- 信息提示 -->
|
||||||
|
<div class="info-text">
|
||||||
|
<strong>💡 提示:</strong>为保证网页运作性能,默认仅读取前20条记录
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- 折叠面板 -->
|
<!-- 折叠面板 -->
|
||||||
<div class="layui-collapse" lay-filter="test">
|
<div class="layui-collapse" lay-accordion>
|
||||||
<div class="layui-colla-item">
|
<div class="layui-colla-item">
|
||||||
<h2 class="layui-colla-title">选择监控源新闻类型</h2>
|
<h2 class="layui-colla-title">📋 选择资讯类型</h2>
|
||||||
<div class="layui-colla-content">
|
<div class="layui-colla-content layui-show">
|
||||||
<div id="button-container" class="layui-btn-group">
|
<div id="button-container">
|
||||||
<button id="sec-news-btn" class="layui-btn">安全新闻</button>
|
<button id="sec-news-btn" class="layui-btn layui-btn-sm">🔒 安全新闻</button>
|
||||||
<button id="tech-passage-btn" class="layui-btn">技术文章</button>
|
<button id="tech-passage-btn" class="layui-btn layui-btn-sm">💻 技术文章</button>
|
||||||
<button id="baidu-news-btn" class="layui-btn">百度新闻</button>
|
<button id="baidu-news-btn" class="layui-btn layui-btn-sm">📊 百度新闻</button>
|
||||||
<button id="github-news-btn" class="layui-btn">GitHub新闻</button>
|
<button id="github-news-btn" class="layui-btn layui-btn-sm">🐙 GitHub动态</button>
|
||||||
<button id="wx-news-btn" class="layui-btn">微信新闻</button>
|
<button id="wx-news-btn" class="layui-btn layui-btn-sm">💬 微信文章</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h4>为保证网页运作性能,默认仅读取前20条记录,若您有需求可自行更改app.py</h4></center>
|
|
||||||
<div id="markdown-content" class="layui-card-body"></div>
|
<div id="markdown-content" class="layui-card-body"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 返回顶部按钮 -->
|
<!-- 返回顶部按钮 -->
|
||||||
<button id="back-to-top" title="Go to top">Top</button>
|
<button id="back-to-top" title="返回顶部">
|
||||||
|
<i class="layui-icon layui-icon-top"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
<!-- 引入 Layui 的 JS -->
|
<!-- 引入 Layui 的 JS -->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/layui-src/dist/layui.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/layui-src/dist/layui.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
// 优化后的JavaScript代码
|
||||||
layui.use(['layer', 'element'], function(){
|
layui.use(['layer', 'element'], function(){
|
||||||
var layer = layui.layer;
|
var layer = layui.layer;
|
||||||
var element = layui.element;
|
var element = layui.element;
|
||||||
@ -125,80 +238,90 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
var titleMap = {
|
var titleMap = {
|
||||||
'/get-sec-news': '安全新闻',
|
'/get-sec-news': '🔒 安全新闻',
|
||||||
'/get-tech-passage': '技术文章',
|
'/get-tech-passage': '💻 技术文章',
|
||||||
'/get-baidu-news': '百度新闻',
|
'/get-baidu-news': '📊 百度新闻',
|
||||||
'/get-github-news': 'GitHub监控',
|
'/get-github-news': '🐙 GitHub动态',
|
||||||
'/get-wx-news': '微信文章监控'
|
'/get-wx-news': '💬 微信文章'
|
||||||
};
|
};
|
||||||
|
|
||||||
function updateTitle(url) {
|
function updateTitle(url) {
|
||||||
document.getElementById('page-title').innerText = titleMap[url] || '历史推送读取';
|
document.getElementById('page-title').innerText = titleMap[url] || '📰 资讯推送中心';
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetchContent(url, buttonId) {
|
function fetchContent(url, buttonId) {
|
||||||
// Disable all buttons
|
// 更新所有按钮状态
|
||||||
Object.keys(buttonMap).forEach(key => {
|
Object.keys(buttonMap).forEach(key => {
|
||||||
document.getElementById(key).disabled = false;
|
const btn = document.getElementById(key);
|
||||||
|
btn.disabled = (key === buttonId);
|
||||||
|
btn.style.opacity = (key === buttonId) ? '0.7' : '1';
|
||||||
});
|
});
|
||||||
// Enable the clicked button
|
|
||||||
document.getElementById(buttonId).disabled = true;
|
|
||||||
|
|
||||||
updateTitle(url);
|
updateTitle(url);
|
||||||
|
|
||||||
|
// 显示加载动画
|
||||||
|
document.getElementById('markdown-content').innerHTML =
|
||||||
|
'<div class="loading"><i class="layui-icon layui-icon-loading layui-anim layui-anim-rotate layui-anim-loop"></i> 加载中...</div>';
|
||||||
|
|
||||||
fetch(url)
|
fetch(url)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(data => {
|
.then(data => {
|
||||||
if (data.content) {
|
if (data.content) {
|
||||||
const htmlContent = marked.parse(data.content);
|
const htmlContent = marked.parse(data.content);
|
||||||
document.getElementById('markdown-content').innerHTML = htmlContent;
|
document.getElementById('markdown-content').innerHTML = htmlContent;
|
||||||
// 添加这一行代码
|
|
||||||
addTargetBlankToLinks();
|
addTargetBlankToLinks();
|
||||||
} else {
|
} else {
|
||||||
document.getElementById('markdown-content').innerHTML = '<p>加载历史推送文件时出错!(推送历史记录为空)</p>';
|
document.getElementById('markdown-content').innerHTML = '<div class="error-message"><p>❌ 加载历史推送文件时出错!(推送历史记录为空)</p></div>';
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error('获取源文件失败:', error);
|
console.error('获取源文件失败:', error);
|
||||||
document.getElementById('markdown-content').innerHTML = '<p>无法加载历史推送文件!</p>';
|
document.getElementById('markdown-content').innerHTML = '<div class="error-message"><p>❌ 无法加载历史推送文件!</p></div>';
|
||||||
layer.msg('加载资源失败', {icon: 5});
|
layer.msg('加载资源失败', {icon: 2});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add event listeners to buttons
|
// 为按钮添加点击事件
|
||||||
Object.keys(buttonMap).forEach(key => {
|
Object.keys(buttonMap).forEach(key => {
|
||||||
document.getElementById(key).addEventListener('click', function() {
|
document.getElementById(key).addEventListener('click', function() {
|
||||||
fetchContent(buttonMap[key], key);
|
fetchContent(buttonMap[key], key);
|
||||||
// Check if the device is mobile
|
|
||||||
|
// 移动设备上自动收起面板
|
||||||
if (isMobileDevice()) {
|
if (isMobileDevice()) {
|
||||||
// Collapse the panel
|
$('.layui-colla-content').removeClass('layui-show');
|
||||||
element.collapse('hide', 'test', 0);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Initial fetch on page load
|
// 页面加载时默认获取安全新闻
|
||||||
var initialButtonId = 'sec-news-btn'; // Default button
|
var initialButtonId = 'sec-news-btn';
|
||||||
fetchContent(buttonMap[initialButtonId], initialButtonId);
|
fetchContent(buttonMap[initialButtonId], initialButtonId);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 优化的滚动检测函数
|
||||||
|
function scrollFunction() {
|
||||||
|
const scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
|
||||||
|
const backToTopBtn = document.getElementById("back-to-top");
|
||||||
|
|
||||||
|
if (scrollTop > 300) {
|
||||||
|
backToTopBtn.style.display = "block";
|
||||||
|
} else {
|
||||||
|
backToTopBtn.style.display = "none";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 显示或隐藏返回顶部按钮
|
// 显示或隐藏返回顶部按钮
|
||||||
window.onscroll = function() {
|
window.onscroll = function() {
|
||||||
scrollFunction();
|
scrollFunction();
|
||||||
};
|
};
|
||||||
|
|
||||||
function scrollFunction() {
|
// 返回顶部按钮点击事件 - 已优化
|
||||||
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
|
|
||||||
document.getElementById("back-to-top").style.display = "block";
|
|
||||||
} else {
|
|
||||||
document.getElementById("back-to-top").style.display = "none";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 返回顶部按钮点击事件
|
|
||||||
document.getElementById("back-to-top").addEventListener("click", function() {
|
document.getElementById("back-to-top").addEventListener("click", function() {
|
||||||
document.body.scrollTop = 0;
|
// 使用更平滑的滚动方式
|
||||||
document.documentElement.scrollTop = 0;
|
window.scrollTo({
|
||||||
|
top: 0,
|
||||||
|
behavior: 'smooth'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// 检测是否为移动设备
|
// 检测是否为移动设备
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user