feat(web): home media sections use 5-up PC / 1-up mobile grid, growth top5
This commit is contained in:
1 parent
1bb5718328
commit
e00331c4c6
4 files changed
+13
-20
No files matched your search
@@ -415,17 +415,11 @@ a.live-chip:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--bo
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.heat-strip {
|
||||
display: grid;
|
||||
grid-auto-flow: column;
|
||||
grid-auto-columns: 210px;
|
||||
gap: 10px;
|
||||
overflow-x: auto;
|
||||
padding-bottom: 4px;
|
||||
scroll-snap-type: x proximity;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
.heat-strip::-webkit-scrollbar { display: none; }
|
||||
/* 统一的响应式媒体网格:移动端 1 列,PC 端 5 列。 */
|
||||
.media-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
|
||||
@media (min-width: 620px) { .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
||||
@media (min-width: 900px) { .media-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
|
||||
@media (min-width: 1280px) { .media-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
|
||||
/* 统一的竖排媒体卡:图 + 两行截断标题 + 作者/数据行 + 高亮数据行。 */
|
||||
.media-card {
|
||||
position: relative;
|
||||
@@ -442,7 +436,6 @@ a.live-chip:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--bo
|
||||
border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
.heat-strip > .media-card { scroll-snap-align: start; }
|
||||
.media-rank {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
|
||||
@@ -15,9 +15,9 @@ function statChip(label, value, { href = null, tone = "" } = {}) {
|
||||
return `<div class="live-chip ${tone}">${inner}</div>`;
|
||||
}
|
||||
|
||||
function heatStrip(items) {
|
||||
function heatGrid(items) {
|
||||
if (!items.length) return emptyState("暂无热度数据", "完成一次快照后这里会出现榜单。");
|
||||
return `<div class="heat-strip">
|
||||
return `<div class="media-grid">
|
||||
${items.map((item, index) => mediaCard(item, {
|
||||
rank: index + 1,
|
||||
meta: `${escapeHtml(item.up_name || "未知 UP")} · ${formatCount(item.metrics?.view)} 播放`,
|
||||
@@ -65,7 +65,7 @@ export async function renderHome(root) {
|
||||
api("/api/overview"),
|
||||
api("/api/videos", { sort: "published", within_days: 14, limit: 5 }),
|
||||
api("/api/videos", { sort: "heat", limit: 5 }),
|
||||
api("/api/videos", { sort: "growth", growth_days: 7, limit: 3 }),
|
||||
api("/api/videos", { sort: "growth", growth_days: 7, limit: 5 }),
|
||||
]);
|
||||
|
||||
const pending = overview.counts.candidates_pending || 0;
|
||||
@@ -112,7 +112,7 @@ export async function renderHome(root) {
|
||||
<a class="text-link" href="/videos?sort=published&within_days=30">查看全部</a>
|
||||
</div>
|
||||
<p class="section-note">按视频发布时间排序,与入库时间无关。</p>
|
||||
<div class="video-list">
|
||||
<div class="media-grid">
|
||||
${published.items.length ? published.items.map((item) => publishedCard(item)).join("")
|
||||
: emptyState("最近 14 天没有新发布视频", "搜索发现的新视频会逐步补充。")}
|
||||
</div>
|
||||
@@ -124,7 +124,7 @@ export async function renderHome(root) {
|
||||
<a class="text-link" href="/videos?sort=growth&growth_days=7">增长榜</a>
|
||||
</div>
|
||||
${growth.available && growth.items.length
|
||||
? `<div class="video-list">${growth.items.map((item, index) => growthCard(item, index)).join("")}</div>`
|
||||
? `<div class="media-grid">${growth.items.map((item, index) => growthCard(item, index)).join("")}</div>`
|
||||
: emptyState("需要至少 2 天快照", growth.reason || "当前只有 1 个数据点,明天开始显示播放增量。")}
|
||||
</section>
|
||||
|
||||
@@ -133,7 +133,7 @@ export async function renderHome(root) {
|
||||
<h2>热度速览</h2>
|
||||
<a class="text-link" href="/videos?sort=heat">完整榜单</a>
|
||||
</div>
|
||||
${heatStrip(heat.items)}
|
||||
${heatGrid(heat.items)}
|
||||
</section>
|
||||
|
||||
${capacity(overview.folders || [])}
|
||||
|
||||
Reference in new issue
Block a user