From 64df5623a58836d0478acca891e528b6526470fb Mon Sep 17 00:00:00 2001 From: SepComet <202308010230@stu.csust.edu.cn> Date: Thu, 7 May 2026 15:59:29 +0800 Subject: [PATCH] Reduce homepage confusion during temporary routing issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a prominent homepage notice for the current reverse-proxy redirect problem and tighten the Gitea activity presentation so the landing page stays readable while users navigate around the temporary deployment constraint. Constraint: Temporary Nginx reverse-proxy redirects can drop :2000 from navigation URLs and cause 502 responses Rejected: Move the warning into secondary pages only | Users need the fix before they leave the homepage Confidence: high Scope-risk: narrow Directive: Remove or rewrite the homepage warning once the备案-backed domain setup eliminates the redirect mismatch Tested: npm run build Not-tested: Live browser verification against the current reverse-proxy deployment --- src/components/GiteaActivity.astro | 65 ++++++++++++++++++++------- src/pages/index.astro | 13 ++++++ src/styles/global.css | 70 ++++++++++++++++++++++++++++-- 3 files changed, 129 insertions(+), 19 deletions(-) diff --git a/src/components/GiteaActivity.astro b/src/components/GiteaActivity.astro index 2a20b52..cb9078a 100644 --- a/src/components/GiteaActivity.astro +++ b/src/components/GiteaActivity.astro @@ -1,7 +1,7 @@ --- import type { GiteaActivityData } from '../data/loaders'; import { site } from '../config'; -import { formatDateTime } from '../utils/datetime'; +import { formatDate, formatDateTime } from '../utils/datetime'; import SyncMeta from './SyncMeta.astro'; interface Props { @@ -12,21 +12,47 @@ const { activity } = Astro.props; const heatmapLevels = ['#0f172a', '#13233e', '#1d4ed8', '#2563eb', '#22c55e']; const heatmapSize = 70; -const heatmapCounts = activity.days.slice(-heatmapSize).map((day) => day.count); +const recentDays = activity.days.slice(-heatmapSize); +const heatmapCounts = recentDays.map((day) => day.count); const maxCount = Math.max(...heatmapCounts, 0); -const heatmap = Array.from({ length: heatmapSize }, (_, index) => { - const count = heatmapCounts[index] ?? 0; - if (count <= 0 || maxCount <= 0) { - return 0; - } +function getCurrentIsoDay() { + const parts = new Intl.DateTimeFormat('en-CA', { + timeZone: 'Asia/Shanghai', + year: 'numeric', + month: '2-digit', + day: '2-digit', + }).formatToParts(new Date()); - return Math.min( - heatmapLevels.length - 1, - Math.max(1, Math.ceil((count / maxCount) * (heatmapLevels.length - 1))), - ); + const year = parts.find((part) => part.type === 'year')?.value ?? '0000'; + const month = parts.find((part) => part.type === 'month')?.value ?? '00'; + const day = parts.find((part) => part.type === 'day')?.value ?? '00'; + return `${year}-${month}-${day}`; +} + +const currentIsoDay = getCurrentIsoDay(); + +const heatmap = recentDays.map((day) => { + const count = day.count ?? 0; + const level = + count <= 0 || maxCount <= 0 + ? 0 + : Math.min( + heatmapLevels.length - 1, + Math.max(1, Math.ceil((count / maxCount) * (heatmapLevels.length - 1))), + ); + + return { + ...day, + level, + displayDate: formatDate(day.date) || day.date, + isToday: day.date === currentIsoDay, + }; }); +const heatmapRangeStart = heatmap[0]?.displayDate; +const heatmapRangeEnd = heatmap.at(-1)?.displayDate; + function cleanText(value?: string) { return value?.replace(/\s+/g, ' ').trim() || ''; } @@ -111,11 +137,12 @@ const isPlaceholder = activity.source === 'placeholder'; />
{ - heatmap.map((level) => ( + heatmap.map((day) => ( 低 → 高
+

+ {heatmapRangeStart && heatmapRangeEnd + ? `最近 70 天(${heatmapRangeStart} - ${heatmapRangeEnd}),左上最早、右下最新;悬停可查看具体日期和提交次数。` + : '最近 70 天,左上最早、右下最新;悬停可查看具体日期和提交次数。'} + 描边高亮表示今天。 +

@@ -135,7 +168,7 @@ const isPlaceholder = activity.source === 'placeholder'; recentActivities.map((item) => (

{item.repo}

-

{item.message}

+

{item.message}

diff --git a/src/pages/index.astro b/src/pages/index.astro index 61f8087..0a9cfa8 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -37,6 +37,19 @@ const featuredProjectsUpdatedAt = getLatestDate(

{site.tagline}

{site.description}

+
+

临时访问说明

+

+ 如果点击顶部导航后页面跳到 + 106.12.111.150/logs + 这类 + 不带 :2000 + 的地址并出现 502,请手动把地址改成 + 106.12.111.150:2000/对应路径 + 即可正常访问其他视图。这个问题是当前 Nginx 反代导致的临时现象,等域名备案完成后会恢复正常。 +

+
+
查看精选项目 阅读开发日志 diff --git a/src/styles/global.css b/src/styles/global.css index 49f42fb..98538b5 100644 --- a/src/styles/global.css +++ b/src/styles/global.css @@ -216,6 +216,37 @@ main { color: var(--muted); } +.hero-notice { + margin: 0 0 1.25rem; + padding: 1rem 1.1rem; + border: 1px solid rgba(245, 158, 11, 0.35); + border-radius: 1rem; + background: linear-gradient(135deg, rgba(245, 158, 11, 0.14), rgba(249, 115, 22, 0.08)); + box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35); +} + +.hero-notice__title { + margin: 0 0 0.5rem; + font-family: 'Archivo', sans-serif; + font-size: 0.98rem; + font-weight: 700; + color: #9a3412; +} + +.hero-notice__body { + margin: 0; + color: #7c2d12; + line-height: 1.75; +} + +.hero-notice code { + padding: 0.12rem 0.4rem; + border-radius: 0.45rem; + background: rgba(255, 255, 255, 0.72); + font-family: 'Fira Code', monospace; + font-size: 0.86em; +} + .hero-actions, .inline-links, .tag-list, @@ -524,7 +555,7 @@ main { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(18rem, 0.85fr); gap: 1.25rem; - align-items: start; + align-items: stretch; } .heatmap { @@ -535,11 +566,19 @@ main { } .heatmap-cell { + position: relative; aspect-ratio: 1; border-radius: 0.5rem; border: 1px solid rgba(148, 163, 184, 0.22); } +.heatmap-cell--today { + border-color: rgba(255, 255, 255, 0.96); + box-shadow: + 0 0 0 2px rgba(59, 130, 246, 0.5), + 0 0 0 4px rgba(255, 255, 255, 0.12); +} + .heatmap-legend { display: flex; align-items: center; @@ -548,6 +587,20 @@ main { font-size: 0.8rem; } +.heatmap-note { + margin: 0.75rem 0 0; + color: rgba(226, 232, 240, 0.86); + font-size: 0.84rem; + line-height: 1.7; +} + +.heatmap-note__today { + display: inline-block; + margin-left: 0.4rem; + color: #dbeafe; + font-weight: 600; +} + .legend-scale { display: inline-flex; gap: 0.35rem; @@ -562,12 +615,16 @@ main { .activity-list { display: grid; + grid-template-rows: repeat(4, minmax(0, 1fr)); gap: 0.75rem; min-width: 0; } .activity-item { + display: flex; + flex-direction: column; min-width: 0; + min-height: 7.5rem; padding: 0.95rem 1rem; border: 1px solid rgba(148, 163, 184, 0.22); border-radius: 1rem; @@ -581,11 +638,16 @@ main { } .activity-panel .activity-copy { + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + overflow: hidden; overflow-wrap: anywhere; } .activity-item__meta { - margin-top: 0.55rem; + margin-top: auto; + padding-top: 0.55rem; } .corner-gallery { @@ -706,8 +768,10 @@ main { } .card-grid, - .status-panel__grid { + .status-panel__grid, + .activity-list { grid-template-columns: 1fr; + grid-template-rows: none; } .section-heading,