feat: 每日积分模式与 Bark 完成提醒

- 按课时类型计分:文档 1 / 视频 3 / 音频 2 / 微课 2,每次 3 分,单日封顶 24 分;满额换类,无内容即停
- 积分计数落 localStorage,跨刷新/重启保留、跨天清零;面板与无头 TUI 都显示今日积分
- 运行器自己收尾时通过 Bark 推送今日积分、完成门数、用时和结束原因;手动停止与 --check 不推送
- 新增 --points-mode / --bark-* 参数及对应 YUN_XUE_TANG_* 环境变量
- 补充 points / notify 离线回归测试与 OpenSpec 配置

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
voidandClaude Sonnet 4.6 committed 2026-11-01 22:19:52 +08:00
1 parent 17217dbeb1
commit 0eb4c40629
31 files changed
+2954 -21

No files matched your search

+39 -1
View File
@@ -1,6 +1,7 @@
// ======== 面板 ========
import { CFG, VERSION, LS_ENABLED, LS_PREFER_SHORT, SS_SHORT_CATALOG, PANEL_ID, TAG } from './config.js';
import { R, S, state, saveRunState } from './state.js';
import { R, S, state, points, saveRunState } from './state.js';
import { LS_POINTS_MODE } from './points.js';
import { route } from './route.js';
import { isLoginPage, startBatch, doLoginAndStart, clearSavedCreds } from './login.js';
@@ -14,6 +15,9 @@ let labelAuto = null;
let labelBatch = null;
let labelShort = null;
let cbPreferShort = null;
let labelPoints = null;
let cbPoints = null;
let pointsEl = null;
let cbAuto = null;
let loginBox = null;
export let loginUserEl = null;
@@ -58,13 +62,20 @@ export function updatePanel() {
}
if (cbAuto) cbAuto.checked = state.autoPlayEnabled;
if (cbPreferShort) cbPreferShort.checked = state.preferShortCourses;
if (cbPoints) cbPoints.checked = state.pointsEnabled;
if (pointsEl) {
pointsEl.style.display = state.pointsEnabled ? 'block' : 'none';
pointsEl.textContent = state.pointsEnabled ? points.summary() : '';
}
const onLogin = isLoginPage();
if (loginBox) loginBox.style.display = onLogin ? 'block' : 'none';
if (labelAuto) labelAuto.style.display = onLogin ? 'none' : 'flex';
if (labelBatch) labelBatch.style.display = onLogin ? 'none' : 'flex';
if (labelShort) labelShort.style.display = onLogin ? 'none' : 'flex';
if (labelPoints) labelPoints.style.display = onLogin ? 'none' : 'flex';
if (statsEl) statsEl.style.display = onLogin ? 'none' : 'block';
if (pointsEl) pointsEl.style.display = onLogin ? 'none' : (state.pointsEnabled ? 'block' : 'none');
if (btnOne) {
// 「停止刷课」只在播放页出现;列表页等位置始终显示「一键刷课」
const onCourse = route() === 'course' && !!S.activeCourse;
@@ -255,6 +266,27 @@ export function buildPanel() {
labelShort.appendChild(cbPreferShort);
labelShort.appendChild(document.createTextNode('优先短课程(时长正序)'));
labelPoints = document.createElement('label');
labelPoints.style.cssText = LABEL_CSS;
cbPoints = document.createElement('input');
cbPoints.type = 'checkbox';
cbPoints.id = 'yun-xue-tang-points-enabled';
cbPoints.checked = state.pointsEnabled;
cbPoints.title = '按课时类型计分:文档1 / 视频3 / 音频2 / 微课2,每天最多 24 分';
cbPoints.addEventListener('change', function () {
state.pointsEnabled = cbPoints.checked;
points.setEnabled(state.pointsEnabled);
try { localStorage.setItem(LS_POINTS_MODE, state.pointsEnabled ? '1' : '0'); } catch (e) {}
R.pointsInventory = null;
R.pointsInventoryFailedAt = 0;
setStatus(state.pointsEnabled
? '已开启每日积分模式:' + points.summary()
: '已关闭每日积分模式,恢复普通刷课');
updatePanel();
});
labelPoints.appendChild(cbPoints);
labelPoints.appendChild(document.createTextNode('每日积分模式(凑满 24 分就停)'));
statusEl = document.createElement('div');
statusEl.id = 'yun-xue-tang-status';
statusEl.textContent = '待机';
@@ -264,6 +296,10 @@ export function buildPanel() {
statsEl.id = 'yun-xue-tang-stats';
statsEl.style.cssText = 'margin-top:2px;color:#aaa;';
pointsEl = document.createElement('div');
pointsEl.id = 'yun-xue-tang-points';
pointsEl.style.cssText = 'margin-top:2px;color:#8ee6c0;';
const hint = document.createElement('div');
hint.textContent = '真实播放计时 · 保持窗口可见';
hint.style.cssText = 'margin-top:6px;color:#777;font-size:11px;';
@@ -280,8 +316,10 @@ export function buildPanel() {
box.appendChild(labelAuto);
box.appendChild(labelBatch);
box.appendChild(labelShort);
box.appendChild(labelPoints);
box.appendChild(statusEl);
box.appendChild(statsEl);
box.appendChild(pointsEl);
box.appendChild(hint);
box.appendChild(footer);
document.documentElement.appendChild(box);