-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
233 lines (212 loc) · 7.72 KB
/
index.html
File metadata and controls
233 lines (212 loc) · 7.72 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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>中华古籍库 中国古代文献全集 中国古文全集 殆知阁</title>
<style>
/* 全局样式 */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
line-height: 1.6;
background-color: #f9f9f9;
color: #333;
}
/* 导航栏样式 */
.modern-navbar {
background: linear-gradient(145deg, #4b6cb7 0%, #182848 100%);
color: white;
padding: 10px 20px;
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 1000;
box-shadow: 0 4px 20px rgba(0,0,0,0.1);
border-bottom: 1px solid rgba(255,255,255,0.1);
}
nav {
max-width: 1200px;
margin: 0 auto;
display: flex;
align-items: center;
gap: 20px;
}
.nav-brand {
font-size: 1.3em;
font-weight: bold;
color: rgba(255,255,255,0.95);
white-space: nowrap;
flex-shrink: 0;
}
.nav-links {
display: flex;
gap: 12px;
align-items: center;
flex-wrap: nowrap;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
flex-grow: 1;
}
.nav-links a {
color: rgba(255,255,255,0.95);
text-decoration: none;
font-size: 0.95em;
transition: all 0.2s ease;
padding: 5px 10px;
border-radius: 4px;
display: flex;
align-items: center;
gap: 6px;
line-height: 1.2;
white-space: nowrap;
flex-shrink: 0;
}
.nav-links a:hover {
background-color: rgba(255,255,255,0.1);
}
/* 随机页面区域 */
.random-section {
max-width: 1200px;
margin: 20px auto;
padding: 20px;
background-color: white;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.random-section h2 {
text-align: center;
margin-bottom: 20px;
color: #4CAF50;
}
.random-links {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
gap: 15px;
}
.random-links li {
background-color: #f1f1f1;
padding: 15px;
border-radius: 5px;
text-align: center;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.random-links a {
text-decoration: none;
color: #333;
font-weight: bold;
transition: color 0.3s ease;
}
.random-links a:hover {
color: #4CAF50;
}
</style>
</head>
<body>
<!-- 导航栏 -->
<div class="modern-navbar">
<nav>
<div class="nav-brand">
<a href="/GuWen/" style="color: inherit; text-decoration: none;">
🏯 中华古籍库
</a>
</div>
<div class="nav-links">
<a href="/GuWen/佛藏/index.html">
<span style="font-size:1.1em">📜</span> 佛藏
</a>
<a href="/GuWen/儒藏/index.html">
<span style="font-size:1.1em">📚</span> 儒藏
</a>
<a href="/GuWen/医藏/index.html">
<span style="font-size:1.1em">🌿</span> 医藏
</a>
<a href="/GuWen/史藏/index.html">
<span style="font-size:1.1em">📖</span> 史藏
</a>
<a href="/GuWen/子藏/index.html">
<span style="font-size:1.1em">🧠</span> 子藏
</a>
<a href="/GuWen/易藏/index.html">
<span style="font-size:1.1em">☯</span> 易藏
</a>
<a href="/GuWen/艺藏/index.html">
<span style="font-size:1.1em">🎨</span> 艺藏
</a>
<a href="/GuWen/诗藏/index.html">
<span style="font-size:1.1em">🌸</span> 诗藏
</a>
<a href="/GuWen/道藏/index.html">
<span style="font-size:1.1em">🌀</span> 道藏
</a>
<a href="/GuWen/集藏/index.html">
<span style="font-size:1.1em">📚</span> 集藏
</a>
</div>
</nav>
</div>
<!-- 随机页面区域 -->
<section class="random-section">
<h2>💡 50 个随机页面</h2>
<ul id="random-links" class="random-links"></ul>
</section>
<script>
// 获取 random_pages/files.json 中的文件列表
async function fetchRandomPagesFiles() {
try {
const response = await fetch('random_pages/files.json');
if (!response.ok) throw new Error(`HTTP 错误! 状态码: ${response.status}`);
return await response.json();
} catch (error) {
console.error('无法加载文件列表:', error);
throw error;
}
}
// 从指定的 JSON 文件中加载数据
async function fetchRandomPagesData(filename) {
try {
const response = await fetch(`random_pages/${filename}`);
if (!response.ok) throw new Error(`HTTP 错误! 状态码: ${response.status}`);
return await response.json();
} catch (error) {
console.error(`无法加载数据文件: ${filename}`, error);
throw error;
}
}
// 从页面列表中随机选择 50 个链接
function getRandomLinks(pages, count = 49) {
if (!pages || pages.length === 0) throw new Error('没有找到任何链接');
const shuffled = [...pages].sort(() => 0.5 - Math.random());
return shuffled.slice(0, count);
}
// 主逻辑
document.addEventListener('DOMContentLoaded', async () => {
try {
// 获取文件列表
const files = await fetchRandomPagesFiles();
// 随机选择一个数据文件
const jsonFiles = files.filter(file => file.endsWith('.json'));
if (jsonFiles.length === 0) throw new Error('没有找到数据文件');
const randomFile = jsonFiles[Math.floor(Math.random() * jsonFiles.length)];
// 加载数据并显示链接
const pages = await fetchRandomPagesData(randomFile);
const randomLinks = getRandomLinks(pages);
const container = document.getElementById('random-links');
randomLinks.forEach(page => {
const li = document.createElement('li');
li.innerHTML = `<a href="${page.url}" target="_blank">${page.name}</a>`;
container.appendChild(li);
});
} catch (error) {
console.error('初始化失败:', error);
const container = document.getElementById('random-links');
container.innerHTML = `<li style="grid-column: 1 / -1; color: red; padding: 20px;">
错误: ${error.message},请检查控制台获取详细信息
</li>`;
}
});
</script>
</body>
</html>