feat(report): 日期列补满区间、博主补上「只有资料没有作品」的号、加条件格式
三个问题一起修: 1. **日期列按完整区间生成**。原先只取「有作品的那几天」,某天断更那一列就消失了 —— 看图的人会以为漏采,而空白本身也是信息。现在固定输出最近 N 个自然日(含今天)。 2. **博主名单改成「账号快照 ∪ 作品」**,和界面一致。线上有 3 个号(昵称是纯数字 uid、作品数 0)只存在于快照表里,一条作品都没有;名单只从作品里取的话它们整行 消失。现在它们会占一行,格子里是空的。 3. **条件格式**:头部加「高亮 [指标] ≥ [数值]」。命中的格子换底色 + 粉色描边, 只在本地重画,不重新请求数据;条件写进地址栏(`cf=likes:1000`)可直接收藏。 细节: * 计数/指标的去重口径不变(同一作品挂两个任务只算一次); * 指标未知仍是 None,参与不了条件格式 —— 不会被当成 0 高亮。 测试 11 条(新增:只有资料没有作品的号仍占一行、日期列是完整区间)。
This commit is contained in:
+68
-2
@@ -46,7 +46,7 @@
|
||||
h1 span { color: var(--cyan); }
|
||||
.spacer { flex: 1; }
|
||||
label { color: var(--muted); font-size: 12px; }
|
||||
select, button, a.btn {
|
||||
select, input, button, a.btn {
|
||||
background: var(--bg-soft);
|
||||
color: var(--text);
|
||||
border: 1px solid var(--line);
|
||||
@@ -58,7 +58,9 @@
|
||||
text-decoration: none;
|
||||
}
|
||||
select { max-width: 200px; }
|
||||
select:hover, button:hover, a.btn:hover { border-color: var(--cyan); }
|
||||
input[type="number"] { width: 78px; cursor: text; }
|
||||
select:hover, input:hover, button:hover, a.btn:hover { border-color: var(--cyan); }
|
||||
input:focus { outline: none; border-color: var(--cyan); }
|
||||
#status { color: var(--muted); font-size: 12px; }
|
||||
#status.error { color: var(--pink); }
|
||||
|
||||
@@ -133,6 +135,14 @@
|
||||
}
|
||||
.untagged { color: var(--muted); font-size: 11px; }
|
||||
.empty { color: #2a3646; }
|
||||
|
||||
/* 条件格式命中的格子。用 inset 描边而不是 box-shadow 扩散:不改变布局,
|
||||
也不会触发整行重排。 */
|
||||
tbody td.hit {
|
||||
background: rgba(244, 114, 182, 0.16);
|
||||
box-shadow: inset 0 0 0 1px rgba(244, 114, 182, 0.55);
|
||||
}
|
||||
tbody tr:hover td.hit { background: rgba(244, 114, 182, 0.24); }
|
||||
.legend {
|
||||
display: flex;
|
||||
gap: 14px;
|
||||
@@ -201,6 +211,16 @@
|
||||
<option value="30">最近 30 天</option>
|
||||
</select>
|
||||
</label>
|
||||
<label title="满足条件的格子会高亮">高亮
|
||||
<select id="cfMetric">
|
||||
<option value="likes">点赞</option>
|
||||
<option value="comments">评论</option>
|
||||
<option value="collected">收藏</option>
|
||||
<option value="shares">分享</option>
|
||||
<option value="count">条数</option>
|
||||
</select>
|
||||
≥ <input id="cfValue" type="number" min="0" step="1" placeholder="数值" />
|
||||
</label>
|
||||
<button id="refresh">刷新</button>
|
||||
<span id="status"></span>
|
||||
<span class="spacer"></span>
|
||||
@@ -229,6 +249,10 @@
|
||||
const wrap = document.getElementById('wrap');
|
||||
const login = document.getElementById('login');
|
||||
const tip = document.getElementById('tip');
|
||||
const cfMetricSel = document.getElementById('cfMetric');
|
||||
const cfValueInput = document.getElementById('cfValue');
|
||||
// 条件格式只在本地重渲染,不重新请求 —— 指标已经随格子一起返回了。
|
||||
let lastData = null;
|
||||
|
||||
function setStatus(text, isError) {
|
||||
statusEl.textContent = text;
|
||||
@@ -244,6 +268,32 @@
|
||||
tip.style.display = 'none';
|
||||
}
|
||||
|
||||
function cfThreshold() {
|
||||
const raw = cfValueInput.value.trim();
|
||||
if (raw === '') return null;
|
||||
const value = Number(raw);
|
||||
return Number.isFinite(value) ? value : null;
|
||||
}
|
||||
|
||||
function cfHit(cell) {
|
||||
if (!cell) return false;
|
||||
const threshold = cfThreshold();
|
||||
if (threshold === null) return false;
|
||||
const value = cell[cfMetricSel.value];
|
||||
return value !== null && value !== undefined && value >= threshold;
|
||||
}
|
||||
|
||||
function syncCfUrl() {
|
||||
const url = new URL(location.href);
|
||||
const threshold = cfThreshold();
|
||||
if (threshold === null) {
|
||||
url.searchParams.delete('cf');
|
||||
} else {
|
||||
url.searchParams.set('cf', cfMetricSel.value + ':' + threshold);
|
||||
}
|
||||
history.replaceState(null, '', url);
|
||||
}
|
||||
|
||||
function buildTip(cell, day, creatorName) {
|
||||
// 用 DOM 拼,不用 innerHTML —— 昵称是平台来的文本,不能当 HTML 解释。
|
||||
tip.textContent = '';
|
||||
@@ -330,12 +380,14 @@
|
||||
td._cell = cell;
|
||||
td.dataset.day = day;
|
||||
td.dataset.creator = creatorName;
|
||||
if (cfHit(cell)) td.classList.add('hit');
|
||||
td.addEventListener('mouseenter', showTip);
|
||||
td.addEventListener('mouseleave', hideTip);
|
||||
return td;
|
||||
}
|
||||
|
||||
function render(data) {
|
||||
lastData = data;
|
||||
wrap.innerHTML = '';
|
||||
if (!data.dates.length) {
|
||||
setStatus('这个范围内没有作品');
|
||||
@@ -444,6 +496,13 @@
|
||||
if (wanted && Array.from(taskSel.options).some((o) => o.value === wanted)) {
|
||||
taskSel.value = wanted;
|
||||
}
|
||||
const cf = params.get('cf');
|
||||
if (cf && cf.includes(':')) {
|
||||
const parts = cf.split(':');
|
||||
const allowed = ['likes', 'comments', 'collected', 'shares', 'count'];
|
||||
if (allowed.includes(parts[0])) cfMetricSel.value = parts[0];
|
||||
cfValueInput.value = parts[1];
|
||||
}
|
||||
await load();
|
||||
}
|
||||
|
||||
@@ -454,6 +513,13 @@
|
||||
});
|
||||
taskSel.addEventListener('change', load);
|
||||
daysSel.addEventListener('change', load);
|
||||
// 条件格式只重画表格,不重新请求数据。
|
||||
const rerender = () => {
|
||||
if (lastData) render(lastData);
|
||||
syncCfUrl();
|
||||
};
|
||||
cfMetricSel.addEventListener('change', rerender);
|
||||
cfValueInput.addEventListener('input', rerender);
|
||||
// 表格滚动时把提示收起来,否则它会停在原地、和格子脱节。
|
||||
wrap.addEventListener('scroll', hideTip);
|
||||
init();
|
||||
|
||||
Reference in New Issue
Block a user