feat: 赋能溢出截断 + 前端按已赋能量禁用按钮
- 单篇赋能上限由硬拒绝改为溢出截断,类似每日经验处理 - 前端弹窗时查询文章已赋能总量,>=10 禁用重赋,>=20 全部禁用 - GetEnergyInfo 支持 ?post_id= 返回 post_energize_total - 文案精简为'赋能成功!+N 经验'等短句
This commit is contained in:
@ -32,6 +32,25 @@
|
||||
capHint.style.display = 'none';
|
||||
lightBtn.disabled = false;
|
||||
heavyBtn.disabled = false;
|
||||
heavyBtn.title = '';
|
||||
heavyBtn.style.opacity = '';
|
||||
lightBtn.title = '';
|
||||
lightBtn.style.opacity = '';
|
||||
}
|
||||
|
||||
function disableHeavy() {
|
||||
heavyBtn.disabled = true;
|
||||
heavyBtn.title = '已达单篇上限(1/2)';
|
||||
heavyBtn.style.opacity = '0.4';
|
||||
}
|
||||
|
||||
function disableAll() {
|
||||
lightBtn.disabled = true;
|
||||
heavyBtn.disabled = true;
|
||||
lightBtn.title = '已达单篇上限(2/2)';
|
||||
lightBtn.style.opacity = '0.4';
|
||||
heavyBtn.title = '已达单篇上限(2/2)';
|
||||
heavyBtn.style.opacity = '0.4';
|
||||
}
|
||||
|
||||
btn.addEventListener('click', function() {
|
||||
@ -39,11 +58,19 @@
|
||||
showToast('无法给自己赋能');
|
||||
return;
|
||||
}
|
||||
fetch('/api/energy/info')
|
||||
fetch('/api/energy/info?post_id=' + postId)
|
||||
.then(function(r) { return r.json(); })
|
||||
.then(function(d) {
|
||||
if (d.success && d.data && d.data.daily_exp_cap_reached) {
|
||||
capHint.style.display = 'block';
|
||||
if (d.success && d.data) {
|
||||
if (d.data.daily_exp_cap_reached) {
|
||||
capHint.style.display = 'block';
|
||||
}
|
||||
var total = d.data.post_energize_total || 0;
|
||||
if (total >= 20) {
|
||||
disableAll();
|
||||
} else if (total >= 10) {
|
||||
disableHeavy();
|
||||
}
|
||||
}
|
||||
showOverlay();
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user