🤠添加随机文章刷新按钮,完善邮箱模板文字替换部分

This commit is contained in:
2024-10-07 23:42:28 +08:00
parent d52f9557f5
commit f2fe18f8ae
9 changed files with 2750 additions and 31 deletions

View File

@ -89,10 +89,24 @@
text-overflow: ellipsis;
}
.random-link-button {
.random-button-container {
position: absolute;
bottom: 20px;
right: 20px;
border: none;
border-radius: 20px;
cursor: pointer;
font-size: 14px;
transition: background-color 0.3s ease-in-out;
}
#refresh-random-article {
margin-right: 10px;
color: #aaaaaa;
text-decoration: none;
}
.random-link-button {
padding: 10px 20px;
border: none;
border-radius: 20px;

View File

@ -65,16 +65,7 @@ function initialize_fc_lite() {
<div>更新时间:${stats.last_updated_time}</div>
`;
// 随机友链卡片
const randomArticle = allArticles[Math.floor(Math.random() * allArticles.length)];
randomArticleContainer.innerHTML = `
<div class="random-container">
<div class="random-container-title">随机钓鱼</div>
<div class="random-title">${randomArticle.title}</div>
<div class="random-author">作者: ${randomArticle.author}</div>
</div>
<button class="random-link-button" onclick="window.open('${randomArticle.link}', '_blank')">过去转转</button>
`;
displayRandomArticle(); // 显示随机友链卡片
const articles = allArticles.slice(start, start + UserConfig.page_turning_number);
@ -123,6 +114,29 @@ function initialize_fc_lite() {
}
}
// 显示随机文章的逻辑
function displayRandomArticle() {
const randomArticle = allArticles[Math.floor(Math.random() * allArticles.length)];
randomArticleContainer.innerHTML = `
<div class="random-container">
<div class="random-container-title">随机钓鱼</div>
<div class="random-title">${randomArticle.title}</div>
<div class="random-author">作者: ${randomArticle.author}</div>
</div>
<div class="random-button-container">
<a href="#" id="refresh-random-article">刷新</a>
<button class="random-link-button" onclick="window.open('${randomArticle.link}', '_blank')">过去转转</button>
</div>
`;
// 为刷新按钮添加事件监听器
const refreshBtn = document.getElementById('refresh-random-article');
refreshBtn.addEventListener('click', function (event) {
event.preventDefault(); // 阻止默认的跳转行为
displayRandomArticle(); // 调用显示随机文章的逻辑
});
}
function showAuthorArticles(author, avatar, link) {
// 如果不存在,则创建模态框结构
if (!document.getElementById('fclite-modal')) {
@ -207,19 +221,9 @@ function initialize_fc_lite() {
};
};
//document.addEventListener("DOMContentLoaded", function() {
// setTimeout(initialize_fc_lite, 0);
//});
//document.addEventListener('pjax:complete', function() {
// setTimeout(initialize_fc_lite, 0);
//});
//setTimeout(initialize_fc_lite, 0);
function whenDOMReady() {
initialize_fc_lite();
}
whenDOMReady();
document.addEventListener("pjax:complete", whenDOMReady);
document.addEventListener("pjax:complete", initialize_fc_lite);