feat: 实现域能系统
- 新增域能完整分层:EnergyLog/PostEnergizeLog/DailyExpSummary 模型、EnergyRepo、EnergyService、EnergyController/AdminEnergyController - 支持签到获取域能(+1)、帖子赋能(-1/-2)/被赋能(+1/+2)、改名扣能(-6)/退款(+6)、删帖扣能(-2) - 赋能单人单帖上限20域能,每日赋能获得经验上限50 - 管理员支持批量调整域能(owner)和查询域能日志(admin) - LV0用户(exp<1)禁止签到和发帖,余额为负可签到/被赋能/删帖但不能赋能/改名 - 首次改名免费(通过HasCompletedTask判重),改名扣能在提交审核时执行 - 移除导航栏手动签到按钮,签到融入域能系统(自动签到) - 新增个人中心域能TAB展示余额和流水日志(近7天) - 新增帖子详情页赋能按钮(轻赋/重赋) - 管理后台新增域能管理和域能日志页面
This commit is contained in:
@ -783,3 +783,97 @@ body {
|
||||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- Energy Tab ---------- */
|
||||
.energy-summary {
|
||||
display: flex;
|
||||
gap: 1.5rem;
|
||||
padding: 1rem 0;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.energy-stat {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: .25rem;
|
||||
}
|
||||
|
||||
.energy-label {
|
||||
font-size: .82rem;
|
||||
color: var(--color-text-light);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.energy-value {
|
||||
font-size: 1.25rem;
|
||||
font-weight: 700;
|
||||
color: var(--color-accent);
|
||||
}
|
||||
|
||||
.energy-log-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.energy-log-empty {
|
||||
text-align: center;
|
||||
padding: 2rem 0;
|
||||
color: #bbb;
|
||||
font-size: .9rem;
|
||||
}
|
||||
|
||||
.energy-log-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: .3rem;
|
||||
padding: .85rem 0;
|
||||
border-bottom: 1px solid #f5f5f5;
|
||||
}
|
||||
|
||||
.energy-log-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.energy-log-meta {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.energy-log-type {
|
||||
font-size: .85rem;
|
||||
font-weight: 600;
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
.energy-log-time {
|
||||
font-size: .78rem;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.energy-log-info {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.energy-log-desc {
|
||||
font-size: .82rem;
|
||||
color: var(--color-text-light);
|
||||
}
|
||||
|
||||
.energy-log-amount {
|
||||
font-size: .88rem;
|
||||
font-weight: 600;
|
||||
white-space: nowrap;
|
||||
margin-left: 1rem;
|
||||
}
|
||||
|
||||
.energy-log-plus .energy-log-amount {
|
||||
color: #2ecc71;
|
||||
}
|
||||
|
||||
.energy-log-minus .energy-log-amount {
|
||||
color: #e74c3c;
|
||||
}
|
||||
|
||||
@ -283,59 +283,6 @@
|
||||
setInterval(pollUnread, POLL_INTERVAL);
|
||||
}
|
||||
|
||||
// ---- Level / Check-in ----
|
||||
var checkInBtn = document.getElementById('checkInBtn');
|
||||
if (checkInBtn) {
|
||||
// 页面加载时查询等级和签到状态
|
||||
fetch('/api/level/info')
|
||||
.then(function (res) {
|
||||
if (!res.ok) return;
|
||||
return res.json();
|
||||
})
|
||||
.then(function (data) {
|
||||
if (!data || !data.success) return;
|
||||
var d = data.data || {};
|
||||
if (d.checked_in) {
|
||||
setCheckInDone();
|
||||
}
|
||||
})
|
||||
.catch(function () {});
|
||||
|
||||
function setCheckInDone() {
|
||||
checkInBtn.classList.add('disabled');
|
||||
var span = checkInBtn.querySelector('span');
|
||||
if (span) span.textContent = '今日已签到';
|
||||
}
|
||||
|
||||
checkInBtn.addEventListener('click', function () {
|
||||
if (checkInBtn.classList.contains('disabled')) return;
|
||||
|
||||
fetch('/api/level/checkin', { method: 'POST' })
|
||||
.then(function (res) {
|
||||
if (!res.ok) return;
|
||||
return res.json();
|
||||
})
|
||||
.then(function (data) {
|
||||
if (!data || !data.success) return;
|
||||
var d = data.data || {};
|
||||
if (!d.checked_in) {
|
||||
setCheckInDone();
|
||||
return;
|
||||
}
|
||||
setCheckInDone();
|
||||
if (d.level_up) {
|
||||
window.MetaLab.toast(document.querySelector('.toast'), '恭喜您!您的等级已提升至 Lv' + d.level, false);
|
||||
}
|
||||
// 刷新等级展示
|
||||
var levelEl = document.querySelector('.nav-dropdown-level');
|
||||
if (levelEl) {
|
||||
levelEl.textContent = 'Lv' + d.level;
|
||||
}
|
||||
})
|
||||
.catch(function () {});
|
||||
});
|
||||
}
|
||||
|
||||
// ---- Auto-refresh token (silent) ----
|
||||
// 场景 A:页面开着时,每 10 分钟静默续期(保持 access token 不过期)
|
||||
// 场景 B:关浏览器 15+ min 后回来,access token 过期但 refresh 仍有效
|
||||
|
||||
Reference in New Issue
Block a user