update
This commit is contained in:
1 parent
ba00741c11
commit
71cc3b4d22
8 files changed
+55
-507
No files matched your search
@@ -70,18 +70,37 @@
|
||||
#markdown-content a:hover {
|
||||
text-decoration: underline; /* 可选:鼠标悬停时显示下划线 */
|
||||
}
|
||||
|
||||
/* 按钮样式调整 */
|
||||
#button-container {
|
||||
flex-direction: column; /* 换行显示按钮 */
|
||||
align-items: center; /* 按钮居中对齐 */
|
||||
}
|
||||
#button-container .layui-btn {
|
||||
margin: 5px 0; /* 增加按钮间距 */
|
||||
width: 90%; /* 调整按钮宽度 */
|
||||
max-width: 300px; /* 设置最大宽度 */
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-container">
|
||||
<center><h1 class="layui-title" id="page-title">历史推送读取</h1><br>
|
||||
<div id="button-container" class="layui-btn-group">
|
||||
<button id="sec-news-btn" class="layui-btn">安全新闻</button>
|
||||
<button id="tech-passage-btn" class="layui-btn">技术文章</button>
|
||||
<button id="baidu-news-btn" class="layui-btn">百度新闻</button>
|
||||
<button id="github-news-btn" class="layui-btn">GitHub新闻</button>
|
||||
<button id="wx-news-btn" class="layui-btn">微信新闻</button>
|
||||
<!-- 折叠面板 -->
|
||||
<div class="layui-collapse" lay-filter="test">
|
||||
<div class="layui-colla-item">
|
||||
<h2 class="layui-colla-title">选择监控源新闻类型</h2>
|
||||
<div class="layui-colla-content">
|
||||
<div id="button-container" class="layui-btn-group">
|
||||
<button id="sec-news-btn" class="layui-btn">安全新闻</button>
|
||||
<button id="tech-passage-btn" class="layui-btn">技术文章</button>
|
||||
<button id="baidu-news-btn" class="layui-btn">百度新闻</button>
|
||||
<button id="github-news-btn" class="layui-btn">GitHub新闻</button>
|
||||
<button id="wx-news-btn" class="layui-btn">微信新闻</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h4>为保证网页运作性能,默认仅读取前20条记录,若您有需求可自行更改app.py</h4></center>
|
||||
<div id="markdown-content" class="layui-card-body"></div>
|
||||
@@ -93,8 +112,9 @@
|
||||
<!-- 引入 Layui 的 JS -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/layui-src/dist/layui.js"></script>
|
||||
<script>
|
||||
layui.use(['layer'], function(){
|
||||
layui.use(['layer', 'element'], function(){
|
||||
var layer = layui.layer;
|
||||
var element = layui.element;
|
||||
|
||||
var buttonMap = {
|
||||
'sec-news-btn': '/get-sec-news',
|
||||
@@ -132,6 +152,8 @@
|
||||
if (data.content) {
|
||||
const htmlContent = marked.parse(data.content);
|
||||
document.getElementById('markdown-content').innerHTML = htmlContent;
|
||||
// 添加这一行代码
|
||||
addTargetBlankToLinks();
|
||||
} else {
|
||||
document.getElementById('markdown-content').innerHTML = '<p>加载历史推送文件时出错!(推送历史记录为空)</p>';
|
||||
}
|
||||
@@ -139,7 +161,7 @@
|
||||
.catch(error => {
|
||||
console.error('获取源文件失败:', error);
|
||||
document.getElementById('markdown-content').innerHTML = '<p>无法加载历史推送文件!</p>';
|
||||
layer.msg('Failed to load markdown.', {icon: 5});
|
||||
layer.msg('加载资源失败', {icon: 5});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -147,6 +169,11 @@
|
||||
Object.keys(buttonMap).forEach(key => {
|
||||
document.getElementById(key).addEventListener('click', function() {
|
||||
fetchContent(buttonMap[key], key);
|
||||
// Check if the device is mobile
|
||||
if (isMobileDevice()) {
|
||||
// Collapse the panel
|
||||
element.collapse('hide', 'test', 0);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -173,6 +200,23 @@
|
||||
document.body.scrollTop = 0;
|
||||
document.documentElement.scrollTop = 0;
|
||||
});
|
||||
|
||||
// 检测是否为移动设备
|
||||
function isMobileDevice() {
|
||||
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
||||
}
|
||||
|
||||
function addTargetBlankToLinks() {
|
||||
var links = document.querySelectorAll('#markdown-content a');
|
||||
links.forEach(function(link) {
|
||||
link.setAttribute('target', '_blank');
|
||||
});
|
||||
}
|
||||
|
||||
// 在页面加载完成后调用该函数
|
||||
window.onload = function() {
|
||||
addTargetBlankToLinks();
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user