feat: 文章详情页右下角悬浮操作栏 + 作者自赋能拦截
- 赞/踩/赋能/收藏/评论/回顶部移至右下角悬浮操作栏,固定定位 - 回顶部按钮页面顶部隐藏,滚动后显示,平滑滚动 - 评论按钮点击定位到评论区(NAV 下方) - 赋能按钮作者可见但禁止自赋能,点击弹出 toast 提示 - 未登录用户赋能/收藏点击跳转登录页 - postReactions 引用统一改为 postFloatBar
This commit is contained in:
@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user