Compare commits
9 Commits
26b8061389
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| cfeee49e68 | |||
| 6d3622555e | |||
| 41641c6f55 | |||
| 6c34c5b564 | |||
| a4850e708f | |||
| 0e917adc3b | |||
| 24fe52cfe3 | |||
| 3595435078 | |||
| c7e51af0e0 |
275
src/components/ContributionHeatmap.astro
Normal file
275
src/components/ContributionHeatmap.astro
Normal file
@@ -0,0 +1,275 @@
|
|||||||
|
---
|
||||||
|
import {dayjs} from "@/lib/format.ts";
|
||||||
|
import type {HeatmapPoint} from "@/types/stats.ts";
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
points?: HeatmapPoint[]
|
||||||
|
/** IANA 时区,用于把时间戳归到某一天 */
|
||||||
|
timeZone?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const {points = [], timeZone = "Asia/Shanghai"} = Astro.props;
|
||||||
|
|
||||||
|
const CELL = 11;
|
||||||
|
const GAP = 3;
|
||||||
|
const STEP = CELL + GAP;
|
||||||
|
const TOP = 20;
|
||||||
|
const LEFT = 26;
|
||||||
|
|
||||||
|
type GridCell = {
|
||||||
|
key: string
|
||||||
|
x: number
|
||||||
|
y: number
|
||||||
|
value: number
|
||||||
|
level: number
|
||||||
|
}
|
||||||
|
|
||||||
|
const toDateText = (key: string) => key.replaceAll("-", ".");
|
||||||
|
|
||||||
|
// 按天聚合:接口按分钟返回,同一天可能有多条
|
||||||
|
const byDay = new Map<string, number>();
|
||||||
|
for (const {timestamp, contributions} of points) {
|
||||||
|
if (!Number.isFinite(timestamp) || !Number.isFinite(contributions)) continue;
|
||||||
|
const key = dayjs(timestamp * 1000).tz(timeZone).format("YYYY-MM-DD");
|
||||||
|
byDay.set(key, (byDay.get(key) ?? 0) + Math.max(0, contributions));
|
||||||
|
}
|
||||||
|
|
||||||
|
const days = [...byDay.keys()].sort();
|
||||||
|
|
||||||
|
const cells: GridCell[] = [];
|
||||||
|
const monthLabels: {x: number, label: string}[] = [];
|
||||||
|
const weekdayLabels = [
|
||||||
|
{row: 0, label: "一"},
|
||||||
|
{row: 2, label: "三"},
|
||||||
|
{row: 4, label: "五"}
|
||||||
|
];
|
||||||
|
|
||||||
|
let weeks = 0;
|
||||||
|
let total = 0;
|
||||||
|
let firstDate = "";
|
||||||
|
let lastDate = "";
|
||||||
|
|
||||||
|
const firstKey = days.at(0);
|
||||||
|
|
||||||
|
if (firstKey) {
|
||||||
|
const first = dayjs.tz(firstKey, timeZone).startOf("day");
|
||||||
|
const today = dayjs().tz(timeZone).startOf("day");
|
||||||
|
const lastData = dayjs.tz(days.at(-1) ?? firstKey, timeZone).startOf("day");
|
||||||
|
// 末尾补到今天,保证最后一列是完整的自然周
|
||||||
|
const endDay = lastData.isAfter(today) ? lastData : today;
|
||||||
|
// 列从周一开始、到周日结束
|
||||||
|
const start = first.subtract((first.day() + 6) % 7, "day");
|
||||||
|
const end = endDay.add(6 - ((endDay.day() + 6) % 7), "day");
|
||||||
|
|
||||||
|
total = [...byDay.values()].reduce((sum, value) => sum + value, 0);
|
||||||
|
firstDate = firstKey;
|
||||||
|
lastDate = endDay.format("YYYY-MM-DD");
|
||||||
|
|
||||||
|
// 用非零数据的分位数划分 4 档,避免个别高峰压扁其余格子
|
||||||
|
const nonZero = [...byDay.values()].filter((value) => value > 0).sort((a, b) => a - b);
|
||||||
|
const quantile = (p: number) => nonZero[Math.min(nonZero.length - 1, Math.floor(p * (nonZero.length - 1)))];
|
||||||
|
const t1 = Math.max(1, quantile(0.4) ?? 1);
|
||||||
|
const t2 = Math.max(t1 + 1, quantile(0.7) ?? 2);
|
||||||
|
const t3 = Math.max(t2 + 1, quantile(0.9) ?? 3);
|
||||||
|
const levelOf = (value: number) =>
|
||||||
|
value <= 0 ? 0 : value <= t1 ? 1 : value <= t2 ? 2 : value <= t3 ? 3 : 4;
|
||||||
|
|
||||||
|
let week = 0;
|
||||||
|
let weekday = 0;
|
||||||
|
for (let cursor = start; !cursor.isAfter(end); cursor = cursor.add(1, "day")) {
|
||||||
|
const key = cursor.format("YYYY-MM-DD");
|
||||||
|
const value = byDay.get(key) ?? 0;
|
||||||
|
|
||||||
|
cells.push({
|
||||||
|
key,
|
||||||
|
x: LEFT + week * STEP,
|
||||||
|
y: TOP + weekday * STEP,
|
||||||
|
value,
|
||||||
|
level: levelOf(value)
|
||||||
|
});
|
||||||
|
|
||||||
|
weekday += 1;
|
||||||
|
if (weekday === 7) {
|
||||||
|
weekday = 0;
|
||||||
|
week += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
weeks = week + (weekday > 0 ? 1 : 0);
|
||||||
|
|
||||||
|
// 每月第一次出现的列打上月份标签
|
||||||
|
let lastMonth = 0;
|
||||||
|
for (let i = 0; i < weeks; i++) {
|
||||||
|
const month = start.add(i, "week").month() + 1;
|
||||||
|
if (month !== lastMonth) {
|
||||||
|
monthLabels.push({x: LEFT + i * STEP, label: `${month}月`});
|
||||||
|
lastMonth = month;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const width = weeks > 0 ? LEFT + (weeks - 1) * STEP + CELL + 2 : 0;
|
||||||
|
const height = TOP + 7 * STEP - GAP + 2;
|
||||||
|
const levels = [0, 1, 2, 3, 4];
|
||||||
|
---
|
||||||
|
|
||||||
|
{
|
||||||
|
firstKey ? (
|
||||||
|
<section class="heatmap">
|
||||||
|
<div class="heatmap__head">
|
||||||
|
<span class="heatmap__range">{toDateText(firstDate)} - {toDateText(lastDate)}</span>
|
||||||
|
<span class="heatmap__total">共 <strong>{total}</strong> 次贡献</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="heatmap__scroll" data-heatmap-scroll>
|
||||||
|
<svg
|
||||||
|
width={width}
|
||||||
|
height={height}
|
||||||
|
viewBox={`0 0 ${width} ${height}`}
|
||||||
|
role="img"
|
||||||
|
aria-label={`代码贡献热力图,${toDateText(firstDate)} 至 ${toDateText(lastDate)},共 ${total} 次贡献`}
|
||||||
|
>
|
||||||
|
{monthLabels.map(({x, label}) => (
|
||||||
|
<text class="heatmap__month" x={x} y={10}>{label}</text>
|
||||||
|
))}
|
||||||
|
{weekdayLabels.map(({row, label}) => (
|
||||||
|
<text class="heatmap__weekday" x={0} y={TOP + row * STEP + CELL - 2}>{label}</text>
|
||||||
|
))}
|
||||||
|
{cells.map((cell) => (
|
||||||
|
<rect
|
||||||
|
class={`heatmap__cell heatmap__cell--${cell.level}`}
|
||||||
|
x={cell.x}
|
||||||
|
y={cell.y}
|
||||||
|
width={CELL}
|
||||||
|
height={CELL}
|
||||||
|
rx={2.5}
|
||||||
|
>
|
||||||
|
<title>{cell.key} · {cell.value > 0 ? `${cell.value} 次贡献` : "无贡献"}</title>
|
||||||
|
</rect>
|
||||||
|
))}
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="heatmap__foot">
|
||||||
|
<div class="heatmap__legend" aria-hidden="true">
|
||||||
|
<span>少</span>
|
||||||
|
{levels.map((level) => <span class={`heatmap__legend-cell heatmap__cell--${level}`}></span>)}
|
||||||
|
<span>多</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
) : (
|
||||||
|
<p class="heatmap__empty">暂无贡献数据</p>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.heatmap {
|
||||||
|
padding: 14px 20px 16px;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-secondary, #6b7280);
|
||||||
|
}
|
||||||
|
|
||||||
|
.heatmap__head {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 12px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heatmap__range {
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
letter-spacing: 0.2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heatmap__total strong {
|
||||||
|
font-weight: 600;
|
||||||
|
color: var(--text-color, #2b2f36);
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heatmap__scroll {
|
||||||
|
overflow-x: auto;
|
||||||
|
overflow-y: hidden;
|
||||||
|
padding-bottom: 4px;
|
||||||
|
scrollbar-width: thin;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heatmap__scroll svg {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heatmap__cell {
|
||||||
|
fill: var(--hm-color, #eceff4);
|
||||||
|
shape-rendering: geometricPrecision;
|
||||||
|
transition: fill 0.12s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heatmap__cell:hover {
|
||||||
|
stroke: var(--text-color, #2b2f36);
|
||||||
|
stroke-width: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* GitHub 贡献图浅色主题配色 */
|
||||||
|
.heatmap__cell--0 { --hm-color: #ebedf0; }
|
||||||
|
.heatmap__cell--1 { --hm-color: #9be9a8; }
|
||||||
|
.heatmap__cell--2 { --hm-color: #40c463; }
|
||||||
|
.heatmap__cell--3 { --hm-color: #30a14e; }
|
||||||
|
.heatmap__cell--4 { --hm-color: #216e39; }
|
||||||
|
|
||||||
|
.heatmap__month,
|
||||||
|
.heatmap__weekday {
|
||||||
|
fill: var(--text-secondary, #6b7280);
|
||||||
|
font-size: 10px;
|
||||||
|
font-family: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heatmap__weekday {
|
||||||
|
text-anchor: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heatmap__foot {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heatmap__legend {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heatmap__legend-cell {
|
||||||
|
display: inline-block;
|
||||||
|
width: 11px;
|
||||||
|
height: 11px;
|
||||||
|
border-radius: 2.5px;
|
||||||
|
background: var(--hm-color, #eceff4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.heatmap__empty {
|
||||||
|
margin: 0;
|
||||||
|
padding: 24px 20px;
|
||||||
|
font-size: 13px;
|
||||||
|
text-align: center;
|
||||||
|
color: var(--text-secondary, #6b7280);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.heatmap {
|
||||||
|
padding: 12px 14px 14px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// 数据从最早一天排到最新一天,窄屏下默认展示最近的部分
|
||||||
|
document.querySelectorAll<HTMLElement>("[data-heatmap-scroll]").forEach((scroller) => {
|
||||||
|
if (scroller.scrollWidth > scroller.clientWidth) {
|
||||||
|
scroller.scrollLeft = scroller.scrollWidth;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -30,11 +30,11 @@ const lowLevel = Math.min(...toc.map((v) => v.level));
|
|||||||
<style>
|
<style>
|
||||||
.toc-mount {
|
.toc-mount {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: -20px;
|
top: 0;
|
||||||
height: 100%;
|
bottom: -64px;
|
||||||
right: -320px;
|
right: -320px;
|
||||||
width: 280px;
|
width: 280px;
|
||||||
padding: 24px 0;
|
padding: 0px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.toc {
|
.toc {
|
||||||
@@ -58,13 +58,17 @@ const lowLevel = Math.min(...toc.map((v) => v.level));
|
|||||||
|
|
||||||
.toc-item:hover {
|
.toc-item:hover {
|
||||||
color: var(--text-title-hover);
|
color: var(--text-title-hover);
|
||||||
font-weight: bold;
|
text-shadow:
|
||||||
|
0.3px 0 0 currentColor,
|
||||||
|
-0.3px 0 0 currentColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
.toc-item.is-active {
|
.toc-item.is-active {
|
||||||
position: relative;
|
position: relative;
|
||||||
color: var(--text-title-hover);
|
color: var(--text-title-hover);
|
||||||
font-weight: bold;
|
text-shadow:
|
||||||
|
0.3px 0 0 currentColor,
|
||||||
|
-0.3px 0 0 currentColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
.toc-item.is-active::before {
|
.toc-item.is-active::before {
|
||||||
|
|||||||
@@ -2,6 +2,6 @@ export const siteConfig = {
|
|||||||
site: "https://ua42.com",
|
site: "https://ua42.com",
|
||||||
siteTitle: "Uroboros",
|
siteTitle: "Uroboros",
|
||||||
postPageSize: 7,
|
postPageSize: 7,
|
||||||
description: "一个人的自留地 ,不欢迎我,也不欢迎你。",
|
description: "love yourself.",
|
||||||
git: "https://git.ua42.com"
|
git: "https://git.ua42.com"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
---
|
---
|
||||||
import "@/styles/global.css";
|
import "@/styles/global.css";
|
||||||
import { siteConfig } from "@/consts.ts";
|
import { siteConfig } from "@/consts.ts";
|
||||||
import PageHeader from "./PageHeader.astro";
|
|
||||||
import PageFooter from "./PageFooter.astro";
|
|
||||||
|
|
||||||
const { siteTitle } = siteConfig;
|
const { siteTitle } = siteConfig;
|
||||||
|
|
||||||
|
|||||||
@@ -36,5 +36,9 @@ import PageFooter from "./PageFooter.astro";
|
|||||||
.container {
|
.container {
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main{
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ const { siteTitle, git } = siteConfig;
|
|||||||
|
|
||||||
@media (max-width: 640px) {
|
@media (max-width: 640px) {
|
||||||
header {
|
header {
|
||||||
margin-top: 12px;
|
padding-top: 12px;
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import timezone from 'dayjs/plugin/timezone';
|
|||||||
dayjs.extend(utc);
|
dayjs.extend(utc);
|
||||||
dayjs.extend(timezone);
|
dayjs.extend(timezone);
|
||||||
|
|
||||||
|
export { dayjs };
|
||||||
|
|
||||||
export const formatDatetime = (date: string,format = 'YYYY-MM-DD HH:mm') => {
|
export const formatDatetime = (date: string,format = 'YYYY-MM-DD HH:mm') => {
|
||||||
return dayjs(date).tz('Asia/Shanghai').format(format);
|
return dayjs(date).tz('Asia/Shanghai').format(format);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -35,6 +35,15 @@ const loadedLangs = new Set<string>(["text"]);
|
|||||||
|
|
||||||
const supportedSet = new Set<string>(SUPPORTED_LANGS);
|
const supportedSet = new Set<string>(SUPPORTED_LANGS);
|
||||||
|
|
||||||
|
const LANG_MAP: Record<string, string> = {
|
||||||
|
markup: "html",
|
||||||
|
html: "html",
|
||||||
|
};
|
||||||
|
|
||||||
|
const normalizeLang = (lang: string): string => {
|
||||||
|
return LANG_MAP[lang] || lang;
|
||||||
|
};
|
||||||
|
|
||||||
const ensureLangLoaded = async (lang: string): Promise<string> => {
|
const ensureLangLoaded = async (lang: string): Promise<string> => {
|
||||||
if (lang === "text" || loadedLangs.has(lang)) return lang;
|
if (lang === "text" || loadedLangs.has(lang)) return lang;
|
||||||
if (!supportedSet.has(lang)) return "text";
|
if (!supportedSet.has(lang)) return "text";
|
||||||
@@ -55,18 +64,20 @@ async function processCodeBlocks(document: Document) {
|
|||||||
if (!preEl || preEl.tagName !== "PRE") continue;
|
if (!preEl || preEl.tagName !== "PRE") continue;
|
||||||
|
|
||||||
const codeContent = codeBlock.textContent || "";
|
const codeContent = codeBlock.textContent || "";
|
||||||
let lang = "text";
|
let rawLang = "text";
|
||||||
for (const cls of codeBlock.classList) {
|
for (const cls of preEl.classList) {
|
||||||
if (cls.startsWith("language-")) {
|
if (cls.startsWith("language-")) {
|
||||||
lang = cls.slice("language-".length);
|
rawLang = cls.slice("language-".length);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lang = await ensureLangLoaded(lang);
|
const lang = normalizeLang(rawLang);
|
||||||
|
|
||||||
|
const loadedLang = await ensureLangLoaded(lang);
|
||||||
|
|
||||||
const highlighted = highlighter.codeToHtml(codeContent, {
|
const highlighted = highlighter.codeToHtml(codeContent, {
|
||||||
lang,
|
lang: loadedLang,
|
||||||
theme: DEFAULT_THEME,
|
theme: DEFAULT_THEME,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,57 @@
|
|||||||
---
|
---
|
||||||
|
import ContributionHeatmap from "@/components/ContributionHeatmap.astro";
|
||||||
|
import { createHttp } from "@/lib/request.ts";
|
||||||
|
import type { HeatmapPoint } from "@/types/stats.ts";
|
||||||
|
|
||||||
const noindex = true;
|
const noindex = true;
|
||||||
|
|
||||||
|
// 与接口 https://admin.ua42.com/api/stats/gitea/x/heatmap 对应
|
||||||
|
const GITEA_USER = "x";
|
||||||
|
|
||||||
|
let heatmap: HeatmapPoint[] = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
const { data } = await createHttp().get<ApiResponse<HeatmapPoint[]>>(
|
||||||
|
`stats/gitea/${GITEA_USER}/heatmap`,
|
||||||
|
{
|
||||||
|
timeout: 5000,
|
||||||
|
retry: 0,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (Array.isArray(data)) heatmap = data;
|
||||||
|
} catch (error) {
|
||||||
|
// 统计接口不可用时不影响入口页展示
|
||||||
|
console.error("[embed/gitea] 热力图数据获取失败", error);
|
||||||
|
}
|
||||||
|
|
||||||
|
const entries = [
|
||||||
|
{ label: "博客地址", desc: "ua42.com", href: "https://ua42.com" },
|
||||||
|
{
|
||||||
|
label: "博客管理后台",
|
||||||
|
desc: "admin.ua42.com · 支持游客查看",
|
||||||
|
href: "https://admin.ua42.com",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "仓库地址",
|
||||||
|
desc: "git.ua42.com/beggin",
|
||||||
|
href: "https://git.ua42.com/beggin",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "博客服务端仓库",
|
||||||
|
desc: "git.ua42.com/beggin/blog-server",
|
||||||
|
href: "https://git.ua42.com/beggin/blog-server",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "博客服务端 API 文档",
|
||||||
|
desc: "dev.ua42.com/docs",
|
||||||
|
href: "https://dev.ua42.com/docs/server-documentation.html",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Panda Dock",
|
||||||
|
desc: "github.com/forestRhapsody/panda-dock",
|
||||||
|
href: "https://github.com/forestRhapsody/panda-dock",
|
||||||
|
},
|
||||||
|
];
|
||||||
---
|
---
|
||||||
|
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
@@ -14,7 +66,7 @@ const noindex = true;
|
|||||||
<meta name="generator" content={Astro.generator} />
|
<meta name="generator" content={Astro.generator} />
|
||||||
<title>Gitea 入口</title>
|
<title>Gitea 入口</title>
|
||||||
<meta name="theme-color" content="#ffffff" />
|
<meta name="theme-color" content="#ffffff" />
|
||||||
<meta name="robots" content="noindex, nofollow">
|
<meta name="robots" content="noindex, nofollow" />
|
||||||
<style>
|
<style>
|
||||||
@import "modern-normalize";
|
@import "modern-normalize";
|
||||||
|
|
||||||
@@ -27,7 +79,9 @@ const noindex = true;
|
|||||||
--primary: #4f6df5;
|
--primary: #4f6df5;
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
*,
|
||||||
|
*::before,
|
||||||
|
*::after {
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,104 +90,165 @@ const noindex = true;
|
|||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
background: var(--bg);
|
background: var(--bg);
|
||||||
color: var(--text-color);
|
color: var(--text-color);
|
||||||
font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
|
font-family:
|
||||||
|
system-ui,
|
||||||
|
-apple-system,
|
||||||
|
"Segoe UI",
|
||||||
|
"PingFang SC",
|
||||||
|
"Microsoft YaHei",
|
||||||
|
sans-serif;
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-container {
|
.page-container {
|
||||||
height: 100vh;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
padding: 24px 24px 24px 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gitea-card {
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 520px;
|
max-width: 900px;
|
||||||
background: var(--card-bg);
|
min-height: 100vh;
|
||||||
border: 1px solid var(--border);
|
margin: 0 auto;
|
||||||
border-radius: 10px;
|
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.gitea-card__title {
|
|
||||||
padding: 14px 20px;
|
|
||||||
font-size: 15px;
|
|
||||||
font-weight: 600;
|
|
||||||
border-bottom: 1px solid var(--border);
|
|
||||||
}
|
|
||||||
|
|
||||||
.gitea-content {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 28px;
|
||||||
|
padding: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.gitea-item {
|
.section {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section__head {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: baseline;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
gap: 16px;
|
gap: 12px;
|
||||||
padding: 13px 20px;
|
margin-bottom: 10px;
|
||||||
font-size: 14px;
|
padding: 0 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.gitea-item + .gitea-item {
|
.section__title {
|
||||||
border-top: 1px solid var(--border);
|
margin: 0;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 1.4;
|
||||||
}
|
}
|
||||||
|
|
||||||
.gitea-item:hover {
|
.section__meta {
|
||||||
background: #fafbfc;
|
font-size: 12px;
|
||||||
}
|
|
||||||
|
|
||||||
.gitea-item__label {
|
|
||||||
color: var(--text-secondary);
|
color: var(--text-secondary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.gitea-item__link {
|
.entry-grid {
|
||||||
color: var(--primary);
|
display: grid;
|
||||||
text-decoration: none;
|
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||||||
white-space: nowrap;
|
gap: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.gitea-item__link:hover {
|
.entry {
|
||||||
text-decoration: underline;
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
padding: 14px 40px 14px 16px;
|
||||||
|
background: var(--card-bg);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
transition:
|
||||||
|
border-color 0.15s ease,
|
||||||
|
box-shadow 0.15s ease,
|
||||||
|
transform 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.entry:hover {
|
||||||
|
border-color: #c7d2fe;
|
||||||
|
box-shadow: 0 4px 14px rgba(79, 109, 245, 0.12);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.entry__label {
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.entry__desc {
|
||||||
|
overflow: hidden;
|
||||||
|
font-size: 12px;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
|
||||||
|
.entry__arrow {
|
||||||
|
position: absolute;
|
||||||
|
top: 14px;
|
||||||
|
right: 16px;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1;
|
||||||
|
color: var(--text-secondary);
|
||||||
|
transition:
|
||||||
|
color 0.15s ease,
|
||||||
|
transform 0.15s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.entry:hover .entry__arrow {
|
||||||
|
color: var(--primary);
|
||||||
|
transform: translate(1px, -1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
width: 100%;
|
||||||
|
background: var(--card-bg);
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.page-container {
|
||||||
|
gap: 20px;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="page-container">
|
<div class="page-container">
|
||||||
<div class="gitea-card">
|
<section class="section">
|
||||||
<div class="gitea-card__title">常用入口</div>
|
<div class="section__head">
|
||||||
<div class="gitea-content">
|
<h2 class="section__title">常用入口</h2>
|
||||||
<div class="gitea-item">
|
|
||||||
<span class="gitea-item__label">博客地址</span>
|
|
||||||
<a class="gitea-item__link" target="_blank" href="https://ua42.com">点击访问</a>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="entry-grid">
|
||||||
|
{entries.map(({ label, desc, href }) => (
|
||||||
|
<a
|
||||||
|
class="entry"
|
||||||
|
href={href}
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>
|
||||||
|
<span class="entry__label">{label}</span>
|
||||||
|
<span class="entry__desc">{desc}</span>
|
||||||
|
<span class="entry__arrow" aria-hidden="true">
|
||||||
|
↗
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
<div class="gitea-item">
|
{heatmap.length > 0 && (
|
||||||
<span class="gitea-item__label">博客管理后台(支持游客查看)</span>
|
<section class="section">
|
||||||
<a class="gitea-item__link" target="_blank" href="https://admin.ua42.com">点击访问</a>
|
<div class="section__head">
|
||||||
</div>
|
<h2 class="section__title">代码贡献</h2>
|
||||||
|
|
||||||
<div class="gitea-item">
|
|
||||||
<span class="gitea-item__label">仓库地址</span>
|
|
||||||
<a class="gitea-item__link" target="_blank" href="https://git.ua42.com/beggin">点击访问</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="gitea-item">
|
|
||||||
<span class="gitea-item__label">博客服务端仓库</span>
|
|
||||||
<a class="gitea-item__link" target="_blank" href="https://git.ua42.com/beggin/blog-server">点击访问</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="gitea-item">
|
|
||||||
<span class="gitea-item__label">博客服务端 API文档</span>
|
|
||||||
<a class="gitea-item__link" target="_blank" href="https://dev.ua42.com/docs/server-documentation.html">点击访问</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="card">
|
||||||
|
<ContributionHeatmap points={heatmap} />
|
||||||
</div>
|
</div>
|
||||||
|
</section>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|||||||
7
src/types/stats.ts
Normal file
7
src/types/stats.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
/** Gitea 贡献热力图接口返回的原始数据点 */
|
||||||
|
export type HeatmapPoint = {
|
||||||
|
/** Unix 秒级时间戳 */
|
||||||
|
timestamp: number
|
||||||
|
/** 该时间点产生的贡献次数 */
|
||||||
|
contributions: number
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user