-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
396 lines (364 loc) · 14.5 KB
/
Copy pathindex.html
File metadata and controls
396 lines (364 loc) · 14.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>XCPC-Math-Finder</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
<style>
body {
margin: 0;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f4f7f6;
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
position: relative;
}
body::before {
content: "";
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url('BG.png');
background-position: center;
background-repeat: no-repeat;
background-size: cover;
filter: brightness(0.75);
z-index: -1;
}
header {
width: 100%;
background-color: #f39c12;
color: white;
padding: 10px 40px;
box-sizing: border-box;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
position: fixed;
top: 0;
z-index: 1000;
}
.header-left { display: flex; align-items: baseline; gap: 15px; }
.header-left h1 { margin: 0; font-size: 1.8em; letter-spacing: 1px; }
.header-left .author { font-size: 1em; opacity: 0.9; }
.header-right { display: flex; gap: 20px; font-size: 1.5em; }
.header-right a { color: white; transition: opacity 0.3s, transform 0.3s; text-decoration: none; }
.header-right a:hover { opacity: 0.8; transform: scale(1.1); }
.sub-header {
margin-top: 80px;
width: 100%;
max-width: 1050px;
display: flex;
justify-content: center;
align-items: center;
gap: 15px;
padding: 20px;
box-sizing: border-box;
}
.sub-header h2 {
margin: 0;
color: #2c3e50;
font-size: 2em;
text-shadow: 0 1px 3px rgba(255,255,255,0.6);
}
.update-capsule {
background-color: rgba(232, 244, 248, 0.6);
backdrop-filter: blur(5px);
color: #2980b9;
padding: 6px 16px;
border-radius: 50px;
font-size: 0.9em;
font-weight: bold;
display: flex;
align-items: center;
gap: 8px;
border: 1px solid rgba(212, 230, 241, 0.6);
}
.main-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 40px;
max-width: 1050px;
width: 100%;
padding: 20px;
box-sizing: border-box;
}
.grid-col {
display: flex;
flex-direction: column;
align-items: center;
gap: 20px;
}
.capsule-group {
display: flex;
flex-direction: column;
gap: 10px;
height: 70px;
justify-content: flex-end;
align-items: center;
width: 100%;
}
.stat-capsule {
background-color: rgba(255, 255, 255, 0.65);
backdrop-filter: blur(5px);
color: #34495e;
padding: 4px 16px;
border-radius: 50px;
font-size: 0.85em;
font-weight: bold;
box-shadow: 0 2px 6px rgba(0,0,0,0.05);
border: 1px solid rgba(238, 238, 238, 0.5);
}
.stat-capsule.empty {
background-color: rgba(255, 255, 255, 0.15);
backdrop-filter: blur(5px);
color: #7f8c8d;
border: 1px dashed rgba(127, 140, 141, 0.6);
box-shadow: none;
}
.nav-card {
display: flex; flex-direction: column; align-items: center; justify-content: center;
width: 100%; height: 200px;
background-color: rgba(255, 255, 255, 0.65);
backdrop-filter: blur(10px);
border-radius: 15px;
text-decoration: none; color: #333; font-size: 1.5em; font-weight: bold;
box-shadow: 0 10px 25px rgba(0,0,0,0.08);
transition: all 0.3s ease;
}
.nav-card:hover {
transform: translateY(-10px);
background-color: rgba(255, 255, 255, 0.8);
box-shadow: 0 15px 30px rgba(0,0,0,0.15);
}
.card-left { border-bottom: 5px solid #3498db; }
.card-center { border-bottom: 5px solid #e74c3c; }
.card-right { border-bottom: 5px solid #2ecc71; }
.sub-text { font-size: 0.5em; color: #555; margin-top: 10px; font-weight: normal; }
@media (max-width: 768px) {
/* 1. 顶端导航栏:压缩边距,缩小字号 */
header {
padding: 10px 15px;
}
.header-left h1 {
font-size: 1.2em;
}
.header-left .author {
display: none; /* 手机端空间有限,隐藏副标题/作者,保持头部干净 */
}
.header-right {
font-size: 1.2em;
gap: 15px;
}
.back-btn {
padding: 6px 12px;
font-size: 0.8em;
}
/* 2. 主页/公共头部布局:转为纵向排列 */
.sub-header {
margin-top: 70px;
flex-direction: column;
text-align: center;
gap: 10px;
}
.sub-header h2 {
font-size: 1.5em;
}
/* 3. 主页卡片网格:降维至单列 */
.main-grid {
grid-template-columns: 1fr;
gap: 30px;
}
.nav-card {
width: 100%;
height: 160px; /* 稍微压低卡片高度 */
font-size: 1.3em;
}
.capsule-group {
height: auto;
flex-direction: row; /* 数据气泡改为横向并排 */
justify-content: center;
gap: 10px;
margin-bottom: -10px;
}
/* 4. 搜索框工具栏:占满屏幕宽度 */
.search-box {
width: 100%;
}
/* 5. 数据表格降级方案:启用内部横向滚动 */
.container {
padding-left: 10px;
padding-right: 10px;
margin-top: 70px; /* 防止被顶栏遮挡 */
}
/* 将表格外层容器(如果需要)或表格本身设为块级并允许横向滚动 */
table {
display: block;
overflow-x: auto;
white-space: nowrap; /* 强制内容不换行,保障表格结构 */
-webkit-overflow-scrolling: touch; /* 提升 iOS 上的滚动顺滑度 */
}
th, td {
padding: 12px 10px;
}
/* 6. 右下角悬浮按钮:缩小并靠边,防止挡住底层表格内容 */
.floating-nav {
bottom: 20px;
right: 15px;
gap: 10px;
}
.btn-jump {
padding: 8px 16px;
font-size: 0.85em;
}
}
</style>
</head>
<body>
<header>
<div class="header-left">
<h1>XCPC-Math-Finder</h1>
<span class="author">by-RavenMan</span>
</div>
<div class="header-right">
<a href="https://github.com/TavenDo/XCPC-Math-Finder" target="_blank" title="GitHub"><i class="fa-brands fa-github"></i></a>
<a href="https://space.bilibili.com/493224666" target="_blank" title="Bilibili"><i class="fa-brands fa-bilibili"></i></a>
</div>
</header>
<div class="sub-header">
<h2>算法竞赛数学训练助手</h2>
<div class="update-capsule" title="GitHub 仓库数据文件最后提交时间">
<i class="fa-regular fa-clock"></i> 上次更新:<span id="last-update-time">获取中...</span>
</div>
</div>
<div class="main-grid">
<div class="grid-col">
<div class="capsule-group">
<div class="stat-capsule">已收录:<span id="total-contests">-</span> 场</div>
<div class="stat-capsule">已做完:<span id="done-contests">-</span> 场</div>
</div>
<a href="contests.html" class="nav-card card-left">
近年XCPC汇总
<span class="sub-text">比赛汇总 / 进度追踪</span>
</a>
</div>
<div class="grid-col">
<div class="capsule-group">
<div class="stat-capsule">已收录:<span id="total-math">-</span> 题</div>
<div class="stat-capsule">已做完:<span id="done-math">-</span> 题</div>
</div>
<a href="Math.html" class="nav-card card-center">
数学题目训练
<span class="sub-text">专项分类 / 针对性刷题单</span>
</a>
</div>
<div class="grid-col">
<div class="capsule-group">
<div class="stat-capsule">已有:<span id="total-tools">-</span> 项</div>
<div class="stat-capsule" id="latest-tool">最新:加载中...</div>
</div>
<a href="tools.html" class="nav-card card-right">
个人小工具收录
<span class="sub-text">百宝箱 / 效率组件</span>
</a>
</div>
</div>
<script>
async function fetchLastUpdate() {
try {
const response = await fetch('https://api.github.com/repos/TavenDo/XCPC-Math-Finder/commits?path=recent_xcpc_contests.json&page=1&per_page=1');
if (response.ok) {
const data = await response.json();
if (data.length > 0) {
const dateObj = new Date(data[0].commit.committer.date);
const formattedDate = `${dateObj.getFullYear()}年${dateObj.getMonth() + 1}月${dateObj.getDate()}日`;
document.getElementById('last-update-time').innerText = formattedDate;
} else {
document.getElementById('last-update-time').innerText = "暂未记录";
}
} else {
document.getElementById('last-update-time').innerText = "暂未获取";
}
} catch (error) {
console.error("无法获取更新时间:", error);
document.getElementById('last-update-time').innerText = "获取失败";
}
}
// 统计第一板块的比赛进度
async function fetchContestStats() {
try {
const response = await fetch('recent_xcpc_contests.json');
if (response.ok) {
const data = await response.json();
document.getElementById('total-contests').innerText = data.length;
}
} catch (error) {
console.error("无法读取本地比赛数据:", error);
document.getElementById('total-contests').innerText = "0";
}
try {
const doneMap = JSON.parse(localStorage.getItem('xcpc_done_records')) || {};
const doneCount = Object.values(doneMap).filter(val => val === true).length;
document.getElementById('done-contests').innerText = doneCount;
} catch (error) {
console.error("无法读取本地存储记录:", error);
document.getElementById('done-contests').innerText = "0";
}
}
// 核心更改:新增逻辑,统计第二板块的数学题进度
async function fetchMathStats() {
try {
const response = await fetch('math_problems.json');
if (response.ok) {
const data = await response.json();
document.getElementById('total-math').innerText = data.length;
}
} catch (error) {
console.error("无法读取本地数学题数据:", error);
document.getElementById('total-math').innerText = "0";
}
try {
// 读取 math_done_records,也就是我们在 math.html 中定义的 localStorage 键名
const doneMap = JSON.parse(localStorage.getItem('math_done_records')) || {};
const doneCount = Object.values(doneMap).filter(val => val === true).length;
document.getElementById('done-math').innerText = doneCount;
} catch (error) {
console.error("无法读取本地数学题存储记录:", error);
document.getElementById('done-math').innerText = "0";
}
}
async function fetchToolsStats() {
try {
const response = await fetch('tools_data.json');
if (response.ok) {
const data = await response.json();
// 1. 渲染已有项总数
document.getElementById('total-tools').innerText = data.length;
if (data.length > 0) {
// 2. 按 priority 降序排列,最高者即为最新/最重要的小工具
const sortedTools = [...data].sort((a, b) => (b.priority || 0) - (a.priority || 0));
document.getElementById('latest-tool').innerText = `最新:${sortedTools[0].name}`;
} else {
document.getElementById('latest-tool').innerText = "最新:暂无工具";
}
}
} catch (error) {
console.error("无法读取小工具配置数据:", error);
document.getElementById('total-tools').innerText = "0";
document.getElementById('latest-tool').innerText = "最新:获取失败";
}
}
// 初始化加载
fetchLastUpdate();
fetchContestStats();
fetchMathStats();
fetchToolsStats();
</script>
</body>
</html>