Skip to content

Commit 90c473e

Browse files
committed
feat: 新增「实验室 Lab」——浏览器里能玩的交互实验
不再局限于文章,给博客加一个可互动的实验室页面。 新增 /lab/,四个纯前端实验(Canvas + 原生 JS,无 CDN,深色模式适配): 1. 生命游戏:点击播种细胞,空格暂停、R 随机、C 清空、单步/运行 2. 曼德博分形:点击放大、右键/滚轮缩放,可无限深入 3. 双摆混沌:拖出混沌轨迹,点击重新设定起始角度 4. 傅里叶绘图:一圈圈旋转箭头逼近心形曲线 首页 hero 主按钮改为「进实验室玩」,导航/页脚同步加入口。
1 parent 282c27c commit 90c473e

5 files changed

Lines changed: 795 additions & 4 deletions

File tree

‎_layouts/default.html‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ <h1><a href="{{ "/" | absolute_url }}">{{ site.title | default: site.github.repo
2626
<p>{{ site.description | default: site.github.project_tagline }}</p>
2727

2828
<nav class="site-nav">
29+
<a href="{{ "/lab/" | relative_url }}">🧪 实验室</a>
2930
<a href="{{ "/search/" | relative_url }}">搜索</a>
3031
<a href="{{ "/reading/" | relative_url }}">好文推荐</a>
3132
<a href="{{ "/stats/" | relative_url }}">数据</a>
@@ -60,6 +61,7 @@ <h1><a href="{{ "/" | absolute_url }}">{{ site.title | default: site.github.repo
6061
<a href="{{ "/about/" | relative_url }}">关于</a> ·
6162
<a href="{{ "/tags/" | relative_url }}">标签</a> ·
6263
<a href="{{ "/search/" | relative_url }}">搜索</a> ·
64+
<a href="{{ "/lab/" | relative_url }}">实验室</a> ·
6365
<a href="{{ "/reading/" | relative_url }}">好文推荐</a> ·
6466
<a href="{{ "/stats/" | relative_url }}">数据</a> ·
6567
<a href="{{ "/random/" | relative_url }}">手气不错</a> ·

‎assets/css/style.scss‎

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,109 @@ kbd {
10531053

10541054
.konami-close:hover { background: var(--link-hover); }
10551055

1056+
/* ==========================================================================
1057+
实验室 Lab
1058+
========================================================================== */
1059+
.lab-badge {
1060+
display: inline-block;
1061+
margin-left: 6px;
1062+
padding: 2px 8px;
1063+
font-size: 12px;
1064+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
1065+
color: #ffffff;
1066+
background: var(--link);
1067+
border-radius: 999px;
1068+
vertical-align: middle;
1069+
}
1070+
1071+
.lab-tabs {
1072+
display: flex;
1073+
flex-wrap: wrap;
1074+
gap: 8px;
1075+
margin: 16px 0 14px;
1076+
}
1077+
1078+
.lab-tab {
1079+
padding: 8px 14px;
1080+
font-family: inherit;
1081+
font-size: 14px;
1082+
color: var(--text);
1083+
background: var(--panel);
1084+
border: 1px solid var(--border);
1085+
border-radius: 6px;
1086+
cursor: pointer;
1087+
transition: border-color .15s ease, color .15s ease, background .15s ease;
1088+
}
1089+
1090+
.lab-tab:hover {
1091+
color: var(--link);
1092+
border-color: var(--link);
1093+
}
1094+
1095+
.lab-tab.active {
1096+
color: #ffffff;
1097+
background: var(--link);
1098+
border-color: var(--link);
1099+
}
1100+
1101+
.lab-panel {
1102+
display: none;
1103+
margin: 0 0 20px;
1104+
}
1105+
1106+
.lab-panel.active { display: block; }
1107+
1108+
.lab-hint {
1109+
margin: 0 0 12px;
1110+
font-size: 13px;
1111+
color: var(--muted);
1112+
}
1113+
1114+
.lab-canvas {
1115+
display: block;
1116+
width: 100%;
1117+
max-width: 560px;
1118+
margin: 0 auto;
1119+
background: var(--code-bg);
1120+
border: 1px solid var(--border);
1121+
border-radius: 6px;
1122+
cursor: crosshair;
1123+
touch-action: none;
1124+
}
1125+
1126+
.lab-controls {
1127+
display: flex;
1128+
flex-wrap: wrap;
1129+
align-items: center;
1130+
gap: 8px;
1131+
margin: 12px auto 0;
1132+
max-width: 560px;
1133+
}
1134+
1135+
.lab-btn {
1136+
padding: 6px 13px;
1137+
font-family: inherit;
1138+
font-size: 13px;
1139+
color: var(--text);
1140+
background: var(--panel);
1141+
border: 1px solid var(--border);
1142+
border-radius: 5px;
1143+
cursor: pointer;
1144+
transition: border-color .15s ease, color .15s ease;
1145+
}
1146+
1147+
.lab-btn:hover {
1148+
color: var(--link);
1149+
border-color: var(--link);
1150+
}
1151+
1152+
.lab-readout {
1153+
margin-left: auto;
1154+
font-size: 12px;
1155+
color: var(--muted);
1156+
font-variant-numeric: tabular-nums;
1157+
}
1158+
10561159
/* ==========================================================================
10571160
打印
10581161
========================================================================== */
@@ -1066,7 +1169,11 @@ kbd {
10661169
.hero-actions,
10671170
.terminal,
10681171
.resume-reading,
1069-
.konami-overlay { display: none !important; }
1172+
.konami-overlay,
1173+
.lab-tabs,
1174+
.lab-controls { display: none !important; }
1175+
1176+
.lab-canvas { max-height: 400px; }
10701177

10711178
:root,
10721179
[data-theme="dark"] {

0 commit comments

Comments
 (0)