feat: 文章详情页右下角悬浮操作栏 + 作者自赋能拦截
- 赞/踩/赋能/收藏/评论/回顶部移至右下角悬浮操作栏,固定定位 - 回顶部按钮页面顶部隐藏,滚动后显示,平滑滚动 - 评论按钮点击定位到评论区(NAV 下方) - 赋能按钮作者可见但禁止自赋能,点击弹出 toast 提示 - 未登录用户赋能/收藏点击跳转登录页 - postReactions 引用统一改为 postFloatBar
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
var commentsSection = document.getElementById('comments');
|
||||
if (!commentsSection) return;
|
||||
|
||||
var postId = commentsSection.closest('.container').querySelector('#postReactions').dataset.postId;
|
||||
var postId = commentsSection.closest('.container').querySelector('#postFloatBar').dataset.postId;
|
||||
var commentsList = document.getElementById('commentsList');
|
||||
var commentsTotal = document.getElementById('commentsTotal');
|
||||
var loadMoreBtn = document.getElementById('commentsLoadMore');
|
||||
|
||||
@ -9,6 +9,20 @@
|
||||
if (!btn || !overlay) return;
|
||||
|
||||
var postId = btn.dataset.id;
|
||||
var isAuthor = btn.dataset.uid && btn.dataset.authorUid &&
|
||||
btn.dataset.uid === btn.dataset.authorUid;
|
||||
|
||||
function showToast(msg) {
|
||||
var toast = document.createElement('div');
|
||||
toast.className = 'energize-toast';
|
||||
toast.textContent = msg;
|
||||
document.body.appendChild(toast);
|
||||
setTimeout(function() { toast.classList.add('show'); }, 10);
|
||||
setTimeout(function() {
|
||||
toast.classList.remove('show');
|
||||
setTimeout(function() { toast.remove(); }, 300);
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
function showOverlay() {
|
||||
overlay.style.display = 'flex';
|
||||
@ -21,6 +35,10 @@
|
||||
}
|
||||
|
||||
btn.addEventListener('click', function() {
|
||||
if (isAuthor) {
|
||||
showToast('无法给自己赋能');
|
||||
return;
|
||||
}
|
||||
fetch('/api/energy/info')
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(function(d) {
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
(function() {
|
||||
var favBtn = document.getElementById('favBtn');
|
||||
var favCountEl = document.getElementById('favCount');
|
||||
var container = document.getElementById('postReactions');
|
||||
var container = document.getElementById('postFloatBar');
|
||||
var overlay = document.getElementById('favOverlay');
|
||||
var closeBtn = document.getElementById('favClose');
|
||||
var folderListEl = document.getElementById('favFolderCheckList');
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// 赞/踩系统
|
||||
(function() {
|
||||
var container = document.getElementById('postReactions');
|
||||
var container = document.getElementById('postFloatBar');
|
||||
var likeBtn = document.getElementById('likeBtn');
|
||||
var dislikeBtn = document.getElementById('dislikeBtn');
|
||||
var likesCountEl = document.getElementById('likesCount');
|
||||
|
||||
Reference in New Issue
Block a user