-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path404.html
More file actions
321 lines (271 loc) · 13.8 KB
/
404.html
File metadata and controls
321 lines (271 loc) · 13.8 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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PF系列插件文档</title>
<meta name="description" content="提供丰富的MCDR插件,助力Minecraft服务器管理">
<!-- Favicon -->
<link rel="icon" href="/assets/img/logo.png">
<!-- TailwindCSS CDN -->
<script src="assets/js/tailwindcss.js" data-cfasync="false"></script>
<!-- Alpine.js CDN -->
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
<!-- FontAwesome CDN -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- css -->
<link rel="stylesheet" href="assets/css/style.css">
<!-- 配置文件 -->
<script type="module">
import config from '/config.js';
window.siteConfig = config;
</script>
<!-- 自定义配置 -->
<script>
// Tailwind 配置
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
colors: {
primary: 'var(--color-primary, #3b82f6)',
},
fontFamily: {
sans: ['system-ui', '-apple-system', 'sans-serif'],
}
}
}
}
</script>
</head>
<body class="bg-gray-50 min-h-screen flex items-center justify-center">
<!-- 装饰性几何图形 -->
<div class="blob-shape w-96 h-96 top-0 right-0"></div>
<div class="blob-shape w-64 h-64 bottom-0 left-0" style="background-color: rgba(var(--color-primary-rgb, 249, 115, 22), 0.05);"></div>
<!-- 404页面内容 -->
<div class="max-w-2xl mx-auto px-4 text-center relative" x-data="countdown()">
<!-- 404图标 -->
<div class="mb-8">
<div class="w-32 h-32 mx-auto bg-red-100 dark:bg-red-900 rounded-full flex items-center justify-center mb-6">
<i class="fas fa-exclamation-triangle text-red-500 text-6xl"></i>
</div>
</div>
<!-- 错误标题 -->
<h1 class="text-6xl font-bold text-gray-800 dark:text-white mb-4">404</h1>
<h2 class="text-3xl font-bold text-gray-700 dark:text-gray-200 mb-6">页面未找到</h2>
<!-- 错误描述 -->
<div class="geometric-shape bg-white dark:bg-gray-800 p-8 mb-8">
<p class="text-lg text-gray-600 dark:text-gray-300 mb-4">
抱歉,您访问的页面不存在或已被移动。
</p>
<!-- 显示用户想访问的页面 -->
<div x-show="targetPage" class="mb-4 p-4 bg-blue-50 dark:bg-blue-900/20 rounded-lg border border-blue-200 dark:border-blue-800">
<p class="text-blue-800 dark:text-blue-200 text-sm mb-2">
您可能想去的页面:
</p>
<p class="text-blue-900 dark:text-blue-100 font-medium" x-text="targetPage"></p>
</div>
<p class="text-gray-500 dark:text-gray-400">
<span x-text="seconds"></span> 秒后将自动重定向...
</p>
</div>
<!-- 倒计时进度条 -->
<div class="mb-8">
<div class="w-full bg-gray-200 dark:bg-gray-700 rounded-full h-2">
<div class="bg-primary h-2 rounded-full transition-all duration-1000 ease-linear"
:style="`width: ${(8 - seconds) / 8 * 100}%`"></div>
</div>
</div>
<!-- 操作按钮 -->
<div class="space-y-4 sm:space-y-0 sm:space-x-4 sm:flex sm:justify-center">
<a href="#" id="main-page-link"
class="inline-block bg-primary hover:bg-primary text-white font-semibold py-3 px-8 rounded-lg shadow-lg transition-all duration-300 transform hover:scale-105">
立即返回主页
<i class="fas fa-home ml-2"></i>
</a>
<a href="javascript:history.back()"
class="inline-block bg-gray-600 hover:bg-gray-700 text-white font-semibold py-3 px-8 rounded-lg shadow-lg transition-all duration-300 transform hover:scale-105">
返回上一页
<i class="fas fa-arrow-left ml-2"></i>
</a>
</div>
<!-- Logo和品牌 -->
<div class="mt-12 text-center">
<div class="flex justify-center mb-4">
<img class="site-logo h-12" id="site-logo" src="assets/img/logo.svg" alt="Logo">
</div>
<p class="text-gray-500 dark:text-gray-400 text-sm" id="site-info">
<span class="text-primary font-semibold"></span>
</p>
</div>
</div>
<script>
// 简化的夜间模式初始化
function initSimpleDarkMode() {
// 获取用户偏好或系统设置
const savedTheme = localStorage.getItem('theme');
const systemPrefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
let initialTheme;
if (savedTheme) {
initialTheme = savedTheme;
} else {
initialTheme = systemPrefersDark ? 'dark' : 'light';
}
// 应用主题
if (initialTheme === 'dark') {
document.documentElement.classList.add('dark');
} else {
document.documentElement.classList.remove('dark');
}
}
// 从配置文件更新网站信息
function updateSiteInfo() {
if (window.siteConfig) {
const config = window.siteConfig;
// 更新Logo
const logoImg = document.getElementById('site-logo');
if (logoImg && config.appearance.logo) {
logoImg.src = config.appearance.logo;
logoImg.alt = config.site.name + ' Logo';
}
// 更新品牌信息
const siteInfo = document.getElementById('site-info');
if (siteInfo && config.site.name && config.site.title) {
siteInfo.innerHTML = `<span class="text-primary font-semibold">${config.site.name}</span> ${config.site.title}`;
}
// 更新页面标题
if (config.site.name) {
document.title = `页面未找到 - ${config.site.name}`;
}
// 更新主页链接
const mainPageLink = document.getElementById('main-page-link');
if (mainPageLink) {
const baseUrl = config.site.base_url.replace(/\/$/, '');
const mainPath = baseUrl ? `${baseUrl}/main/` : '/main/';
mainPageLink.href = mainPath;
}
// 更新主题色
if (config.appearance.theme_color) {
document.documentElement.style.setProperty('--color-primary', config.appearance.theme_color);
// 提取RGB值
const hexToRgb = (hex) => {
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
};
const rgbValues = hexToRgb(config.appearance.theme_color);
if (rgbValues) {
document.documentElement.style.setProperty('--color-primary-rgb', `${rgbValues.r}, ${rgbValues.g}, ${rgbValues.b}`);
}
}
}
}
function countdown() {
return {
seconds: 8,
targetPage: '',
init() {
// 初始化夜间模式
initSimpleDarkMode();
// 更新网站信息
updateSiteInfo();
// 解析当前URL,提取目标页面信息
this.parseTargetPage();
// 开始倒计时
const timer = setInterval(() => {
this.seconds--;
if (this.seconds <= 0) {
clearInterval(timer);
this.redirect();
}
}, 1000);
},
parseTargetPage() {
try {
const currentPath = window.location.pathname;
const searchParams = window.location.search;
const hash = window.location.hash;
// 检查是否是从404.html访问的(带参数)
if (currentPath.endsWith('/404.html') || currentPath.endsWith('404.html')) {
// 如果404.html带有参数,说明用户想访问main/页面的对应内容
if (searchParams || hash) {
let targetPath = 'main/' + searchParams + hash;
// 解码URL编码
try {
targetPath = decodeURIComponent(targetPath);
} catch (e) {
// 如果解码失败,使用原始路径
}
// 美化显示路径
let displayPath = targetPath;
// 替换URL编码的字符
displayPath = displayPath.replace(/%20/g, ' ');
displayPath = displayPath.replace(/%23/g, '#');
// 限制显示长度
if (displayPath.length > 60) {
displayPath = displayPath.substring(0, 57) + '...';
}
this.targetPage = `"${displayPath}"`;
}
} else {
// 如果不是404.html,显示用户原本想访问的页面
let fullPath = currentPath + searchParams + hash;
// 移除开头的斜杠
if (fullPath.startsWith('/')) {
fullPath = fullPath.substring(1);
}
// 如果路径不为空
if (fullPath) {
// 解码URL编码
try {
fullPath = decodeURIComponent(fullPath);
} catch (e) {
// 如果解码失败,使用原始路径
}
// 美化显示路径
let displayPath = fullPath;
// 移除常见的文件扩展名
displayPath = displayPath.replace(/\.(html|md)(\?|#|$)/, '$1');
// 替换URL编码的字符
displayPath = displayPath.replace(/%20/g, ' ');
displayPath = displayPath.replace(/%23/g, '#');
// 限制显示长度
if (displayPath.length > 60) {
displayPath = displayPath.substring(0, 57) + '...';
}
this.targetPage = `"${displayPath}"`;
}
}
} catch (error) {
console.warn('解析目标页面失败:', error);
this.targetPage = '';
}
},
redirect() {
// 获取当前URL的搜索参数和hash
const searchParams = window.location.search;
const hash = window.location.hash;
// 动态获取base_url配置并重定向到主页
if (window.siteConfig) {
const baseUrl = window.siteConfig.site.base_url.replace(/\/$/, '');
const mainPath = baseUrl ? `${baseUrl}/main/` : '/main/';
window.location.href = mainPath + searchParams + hash;
} else {
// 兜底方案
window.location.href = '/main/' + searchParams + hash;
}
}
}
}
// 页面加载完成后立即初始化夜间模式(不等Alpine.js)
document.addEventListener('DOMContentLoaded', () => {
initSimpleDarkMode();
// 等待配置加载完成后更新网站信息
setTimeout(updateSiteInfo, 100);
});
</script>
</body>
</html>