diff --git a/api/reports/matrix.html b/api/reports/matrix.html index ccb259e..4a9ed4b 100644 --- a/api/reports/matrix.html +++ b/api/reports/matrix.html @@ -102,21 +102,48 @@ font-weight: 500; } tbody td { + position: relative; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); - padding: 5px 8px; + /* 底部留一条给左下角的作品条数,别让它压到标签上。 */ + padding: 4px 8px 15px; white-space: nowrap; vertical-align: top; - min-width: 92px; + min-width: 112px; } tbody tr:hover th, tbody tr:hover td { background: #131c28; } - .count { - display: inline-block; - min-width: 16px; - margin-right: 5px; - color: var(--cyan); + /* 一格的主角:点赞 / 评论。标签是分类,数字才是「这条发得怎么样」。 */ + .cell-metrics { + display: flex; + gap: 8px; + margin-bottom: 2px; font-variant-numeric: tabular-nums; + line-height: 1.4; + } + .cell-metrics span { font-size: 12px; } + .cell-metrics b { + margin-right: 2px; + color: var(--muted); + font-weight: 400; + font-size: 10px; + } + .cell-metrics .like { color: var(--pink); } + .cell-metrics .comment { color: var(--cyan); } + + /* 左下角的作品条数:是参照信息,压暗、贴角,不参与主视觉。 */ + .cell-count { + position: absolute; + left: 5px; + bottom: 1px; + min-width: 14px; + padding: 0 3px; + border-radius: 3px; + background: rgba(123, 139, 163, 0.14); + color: var(--muted); + font-size: 10px; + font-variant-numeric: tabular-nums; + line-height: 1.5; } .tag { display: inline-block; @@ -260,7 +287,8 @@
名字左边 = 粉丝数 - N = 当天发出的作品条数 + 赞 / 评 = 当天这些作品的点赞 / 评论 + 左下角数字 = 当天作品条数 无标签 = 发了但没打标签 空白 = 当天没发作品 鼠标停到格子上可以看当天的点赞 / 评论 / 收藏 / 分享 @@ -290,6 +318,30 @@ return Number(value).toLocaleString('zh-CN'); } + /** 格子里的数字要短:一万以上用「万」,否则一行放不下赞和评两个数。 */ + function compact(value) { + if (value === null || value === undefined) return '—'; + const number = Number(value); + if (!Number.isFinite(number)) return '—'; + if (Math.abs(number) >= 100000000) { + return (number / 100000000).toFixed(1).replace(/\.0$/, '') + '亿'; + } + if (Math.abs(number) >= 10000) { + return (number / 10000).toFixed(1).replace(/\.0$/, '') + '万'; + } + return number.toLocaleString('zh-CN'); + } + + function metricNode(label, kind, value) { + const span = document.createElement('span'); + span.className = kind; + const name = document.createElement('b'); + name.textContent = label; + span.appendChild(name); + span.appendChild(document.createTextNode(compact(value))); + return span; + } + function hideTip() { tip.style.display = 'none'; } @@ -414,10 +466,12 @@ td.appendChild(dot); return td; } - const count = document.createElement('span'); - count.className = 'count'; - count.textContent = cell.count; - td.appendChild(count); + // 主角:点赞 / 评论。数字未知时显示「—」,不是 0。 + const metrics = document.createElement('div'); + metrics.className = 'cell-metrics'; + metrics.appendChild(metricNode('赞', 'like', cell.likes)); + metrics.appendChild(metricNode('评', 'comment', cell.comments)); + td.appendChild(metrics); if (!cell.tags || cell.tags.length === 0) { const none = document.createElement('span'); @@ -433,6 +487,13 @@ } } + // 作品条数放左下角。 + const count = document.createElement('span'); + count.className = 'cell-count'; + count.textContent = cell.count; + count.title = '当天共 ' + cell.count + ' 条作品'; + td.appendChild(count); + td._cell = cell; td.dataset.day = day; td.dataset.creator = creatorName;