feat: git嵌入页新增gitea贡献统计
This commit is contained in:
@@ -1,144 +1,254 @@
|
||||
---
|
||||
import ContributionHeatmap from "@/components/ContributionHeatmap.astro";
|
||||
import { createHttp } from "@/lib/request.ts";
|
||||
import type { HeatmapPoint } from "@/types/stats.ts";
|
||||
|
||||
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>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
|
||||
/>
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.ico"/>
|
||||
<meta name="generator" content={Astro.generator}/>
|
||||
<title>Gitea 入口</title>
|
||||
<meta name="theme-color" content="#ffffff"/>
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
<style>
|
||||
@import "modern-normalize";
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta
|
||||
name="viewport"
|
||||
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
|
||||
/>
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
|
||||
<meta name="generator" content={Astro.generator} />
|
||||
<title>Gitea 入口</title>
|
||||
<meta name="theme-color" content="#ffffff" />
|
||||
<meta name="robots" content="noindex, nofollow" />
|
||||
<style>
|
||||
@import "modern-normalize";
|
||||
|
||||
:root {
|
||||
--bg: #f6f7f9;
|
||||
--card-bg: #ffffff;
|
||||
--border: #e5e7eb;
|
||||
--text-color: #2b2f36;
|
||||
--text-secondary: #6b7280;
|
||||
--primary: #4f6df5;
|
||||
}
|
||||
:root {
|
||||
--bg: #f6f7f9;
|
||||
--card-bg: #ffffff;
|
||||
--border: #e5e7eb;
|
||||
--text-color: #2b2f36;
|
||||
--text-secondary: #6b7280;
|
||||
--primary: #4f6df5;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
*,
|
||||
*::before,
|
||||
*::after {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
background: var(--bg);
|
||||
color: var(--text-color);
|
||||
font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
background: var(--bg);
|
||||
color: var(--text-color);
|
||||
font-family:
|
||||
system-ui,
|
||||
-apple-system,
|
||||
"Segoe UI",
|
||||
"PingFang SC",
|
||||
"Microsoft YaHei",
|
||||
sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
.page-container {
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
padding: 24px 24px 24px 24px;
|
||||
}
|
||||
.page-container {
|
||||
width: 100%;
|
||||
max-width: 900px;
|
||||
min-height: 100vh;
|
||||
margin: 0 auto;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
gap: 28px;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.gitea-card {
|
||||
width: 100%;
|
||||
max-width: 520px;
|
||||
background: var(--card-bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
|
||||
overflow: hidden;
|
||||
}
|
||||
.section {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.gitea-card__title {
|
||||
padding: 14px 20px;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.section__head {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 10px;
|
||||
padding: 0 2px;
|
||||
}
|
||||
|
||||
.gitea-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.section__title {
|
||||
margin: 0;
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.gitea-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
padding: 13px 20px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.section__meta {
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.gitea-item + .gitea-item {
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
.entry-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.gitea-item:hover {
|
||||
background: #fafbfc;
|
||||
}
|
||||
.entry {
|
||||
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;
|
||||
}
|
||||
|
||||
.gitea-item__label {
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
.entry:hover {
|
||||
border-color: #c7d2fe;
|
||||
box-shadow: 0 4px 14px rgba(79, 109, 245, 0.12);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.gitea-item__link {
|
||||
color: var(--primary);
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.entry__label {
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.gitea-item__link:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="page-container">
|
||||
<div class="gitea-card">
|
||||
<div class="gitea-card__title">常用入口</div>
|
||||
<div class="gitea-content">
|
||||
<div class="gitea-item">
|
||||
<span class="gitea-item__label">博客地址</span>
|
||||
<a class="gitea-item__link" target="_blank" href="https://ua42.com">点击访问</a>
|
||||
</div>
|
||||
.entry__desc {
|
||||
overflow: hidden;
|
||||
font-size: 12px;
|
||||
color: var(--text-secondary);
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
<div class="gitea-item">
|
||||
<span class="gitea-item__label">博客管理后台(支持游客查看)</span>
|
||||
<a class="gitea-item__link" target="_blank" href="https://admin.ua42.com">点击访问</a>
|
||||
</div>
|
||||
.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;
|
||||
}
|
||||
|
||||
<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>
|
||||
.entry:hover .entry__arrow {
|
||||
color: var(--primary);
|
||||
transform: translate(1px, -1px);
|
||||
}
|
||||
|
||||
<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>
|
||||
.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;
|
||||
}
|
||||
|
||||
<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>
|
||||
@media (max-width: 640px) {
|
||||
.page-container {
|
||||
gap: 20px;
|
||||
padding: 16px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="page-container">
|
||||
<section class="section">
|
||||
<div class="section__head">
|
||||
<h2 class="section__title">常用入口</h2>
|
||||
</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">
|
||||
<span class="gitea-item__label">Panda Dock</span>
|
||||
<a class="gitea-item__link" target="_blank" href="https://github.com/forestRhapsody/panda-dock">点击访问</a>
|
||||
</div>
|
||||
{heatmap.length > 0 && (
|
||||
<section class="section">
|
||||
<div class="section__head">
|
||||
<h2 class="section__title">代码贡献</h2>
|
||||
</div>
|
||||
<div class="card">
|
||||
<ContributionHeatmap points={heatmap} />
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user