generated from dellevin/template
博客文章优化
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
/* 博客文章按钮容器 */
|
||||
.blog-posts-btn-container {
|
||||
position: fixed;
|
||||
top: 95px;
|
||||
top: 115px;
|
||||
right: 80px;
|
||||
z-index: 999;
|
||||
}
|
||||
@@ -19,14 +19,14 @@
|
||||
background: #fff;
|
||||
border: 1px solid #e8e8e8;
|
||||
border-radius: 50%;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 3px;
|
||||
gap: 4px;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
@@ -35,20 +35,20 @@
|
||||
background: #fff;
|
||||
border: 1px solid #e8e8e8;
|
||||
border-radius: 50%;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 3px;
|
||||
gap: 4px;
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
.btn-label {
|
||||
font-size: 12px;
|
||||
font-size: 13px;
|
||||
color: #666;
|
||||
line-height: 1;
|
||||
}
|
||||
@@ -62,8 +62,8 @@
|
||||
|
||||
.guestbook-btn svg,
|
||||
.blog-posts-btn svg {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.guestbook-btn svg path,
|
||||
|
||||
@@ -142,35 +142,47 @@
|
||||
|
||||
// 追加文章
|
||||
function appendPosts(posts) {
|
||||
const container = document.querySelector('.blog-posts-container');
|
||||
const loadMoreBtn = document.querySelector('.load-more-btn');
|
||||
const oldTip = document.querySelector('.load-complete');
|
||||
const containers = document.querySelectorAll('.blog-posts-container');
|
||||
const loadMoreBtns = document.querySelectorAll('.load-more-btn');
|
||||
const oldTips = document.querySelectorAll('.load-complete');
|
||||
|
||||
if (!container) return;
|
||||
if (containers.length === 0) {
|
||||
console.error('未找到 .blog-posts-container 容器');
|
||||
return;
|
||||
}
|
||||
|
||||
posts.forEach(post => {
|
||||
const div = document.createElement('div');
|
||||
div.innerHTML = renderPostItem(post);
|
||||
container.appendChild(div.firstElementChild);
|
||||
// 向所有容器追加新文章
|
||||
containers.forEach(container => {
|
||||
posts.forEach(post => {
|
||||
const div = document.createElement('div');
|
||||
div.innerHTML = renderPostItem(post);
|
||||
container.appendChild(div.firstElementChild);
|
||||
});
|
||||
});
|
||||
|
||||
// 移除旧的加载更多按钮和提示
|
||||
if (loadMoreBtn) loadMoreBtn.remove();
|
||||
if (oldTip) oldTip.remove();
|
||||
// 移除所有旧的加载更多按钮和提示
|
||||
loadMoreBtns.forEach(btn => btn.remove());
|
||||
oldTips.forEach(tip => tip.remove());
|
||||
|
||||
// 添加新的加载更多按钮或提示
|
||||
// 向所有容器后添加新的加载更多按钮或提示
|
||||
if (hasMore) {
|
||||
const btn = document.createElement('button');
|
||||
btn.className = 'load-more-btn';
|
||||
btn.textContent = '点击加载更多';
|
||||
btn.onclick = window.loadMoreBlogPosts;
|
||||
container.after(btn);
|
||||
containers.forEach(container => {
|
||||
const btn = document.createElement('button');
|
||||
btn.className = 'load-more-btn';
|
||||
btn.textContent = '点击加载更多';
|
||||
btn.onclick = window.loadMoreBlogPosts;
|
||||
container.after(btn);
|
||||
});
|
||||
} else {
|
||||
const tip = document.createElement('div');
|
||||
tip.className = 'load-complete';
|
||||
tip.textContent = '已显示全部';
|
||||
container.after(tip);
|
||||
containers.forEach(container => {
|
||||
const tip = document.createElement('div');
|
||||
tip.className = 'load-complete';
|
||||
tip.textContent = '已显示全部';
|
||||
container.after(tip);
|
||||
});
|
||||
}
|
||||
|
||||
console.log(`成功追加 ${posts.length} 篇文章到 ${containers.length} 个容器,当前页码: ${currentPage}`);
|
||||
}
|
||||
|
||||
// 渲染单个文章项
|
||||
|
||||
@@ -70,4 +70,8 @@ const translationsEN = {
|
||||
guestbook_submit_success: "Message submitted successfully!",
|
||||
guestbook_submit_error: "Failed to submit message, please try again",
|
||||
guestbook_required_nickname: "Please enter a nickname",
|
||||
// Top-right buttons
|
||||
btn_guestbook: "Guestbook",
|
||||
btn_blog_posts: "Blog Posts",
|
||||
blog_latest_posts: "Latest Posts",
|
||||
};
|
||||
|
||||
@@ -70,4 +70,8 @@ const translationsZH = {
|
||||
guestbook_submit_success: "留言提交成功!",
|
||||
guestbook_submit_error: "留言提交失败,请重试",
|
||||
guestbook_required_nickname: "请输入昵称",
|
||||
// 右上角按钮
|
||||
btn_guestbook: "留言板",
|
||||
btn_blog_posts: "博客文章",
|
||||
blog_latest_posts: "最新文章",
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user