feat(nginx): 为 37point2.cn 网站的 404 页面添加多语言支持

- 添加简体中文和英文的内容切换
- 根据用户浏览器语言自动设置页面内容
- 更新页面标题、标题、消息内容和按钮文本
- 保持原有的页面样式和交互效果
This commit is contained in:
2025-07-24 15:55:43 +08:00
parent 5ad499560b
commit 21ddacee21

View File

@@ -1,9 +1,9 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="auto">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Page Not Found - 404</title> <title id="page-title">Page Not Found - 404</title>
<style> <style>
:root { :root {
--primary-color: #4361ee; --primary-color: #4361ee;
@@ -12,13 +12,13 @@
--bg-color: #f8f9fa; --bg-color: #f8f9fa;
--error-color: #ef233c; --error-color: #ef233c;
} }
* { * {
margin: 0; margin: 0;
padding: 0; padding: 0;
box-sizing: border-box; box-sizing: border-box;
} }
body { body {
font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
background-color: var(--bg-color); background-color: var(--bg-color);
@@ -32,12 +32,12 @@
padding: 2rem; padding: 2rem;
text-align: center; text-align: center;
} }
.container { .container {
max-width: 600px; max-width: 600px;
width: 100%; width: 100%;
} }
.error-code { .error-code {
font-size: 8rem; font-size: 8rem;
font-weight: 800; font-weight: 800;
@@ -46,7 +46,7 @@
position: relative; position: relative;
display: inline-block; display: inline-block;
} }
.error-code::after { .error-code::after {
content: '404'; content: '404';
position: absolute; position: absolute;
@@ -56,26 +56,26 @@
z-index: -1; z-index: -1;
transform: scale(1.5); transform: scale(1.5);
} }
h1 { h1 {
font-size: 2.5rem; font-size: 2.5rem;
margin-bottom: 1rem; margin-bottom: 1rem;
color: var(--text-color); color: var(--text-color);
} }
p { p {
font-size: 1.1rem; font-size: 1.1rem;
margin-bottom: 2rem; margin-bottom: 2rem;
opacity: 0.9; opacity: 0.9;
} }
.actions { .actions {
display: flex; display: flex;
gap: 1rem; gap: 1rem;
justify-content: center; justify-content: center;
flex-wrap: wrap; flex-wrap: wrap;
} }
.btn { .btn {
display: inline-block; display: inline-block;
padding: 0.8rem 1.8rem; padding: 0.8rem 1.8rem;
@@ -86,33 +86,33 @@
border: none; border: none;
cursor: pointer; cursor: pointer;
} }
.btn-primary { .btn-primary {
background-color: var(--primary-color); background-color: var(--primary-color);
color: white; color: white;
} }
.btn-primary:hover { .btn-primary:hover {
background-color: var(--secondary-color); background-color: var(--secondary-color);
transform: translateY(-2px); transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(67, 97, 238, 0.3); box-shadow: 0 5px 15px rgba(67, 97, 238, 0.3);
} }
.btn-secondary { .btn-secondary {
background-color: transparent; background-color: transparent;
color: var(--primary-color); color: var(--primary-color);
border: 2px solid var(--primary-color); border: 2px solid var(--primary-color);
} }
.btn-secondary:hover { .btn-secondary:hover {
background-color: rgba(67, 97, 238, 0.1); background-color: rgba(67, 97, 238, 0.1);
transform: translateY(-2px); transform: translateY(-2px);
} }
.animation { .animation {
animation: float 6s ease-in-out infinite; animation: float 6s ease-in-out infinite;
} }
@keyframes float { @keyframes float {
0%, 100% { 0%, 100% {
transform: translateY(0); transform: translateY(0);
@@ -121,12 +121,12 @@
transform: translateY(-20px); transform: translateY(-20px);
} }
} }
@media (max-width: 768px) { @media (max-width: 768px) {
.error-code { .error-code {
font-size: 6rem; font-size: 6rem;
} }
h1 { h1 {
font-size: 2rem; font-size: 2rem;
} }
@@ -134,28 +134,47 @@
</style> </style>
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<div class="error-code animation">404</div> <div class="error-code animation">404</div>
<h1>Page Not Found</h1> <h1 id="heading">Page Not Found</h1>
<p>The page you're looking for might have been moved, deleted, or doesn't exist.</p> <p id="message">The page you're looking for might have been moved, deleted, or doesn't exist.</p>
<div class="actions"> <div class="actions">
<a href="/" class="btn btn-primary">Go to Homepage</a> <a href="/" class="btn btn-primary" id="home-btn">Go to Homepage</a>
<a href="javascript:history.back()" class="btn btn-secondary">Go Back</a> <a href="javascript:history.back()" class="btn btn-secondary" id="back-btn">Go Back</a>
</div>
</div> </div>
</div>
<script> <script>
// Console message // Language detection and content switching
console.log('%c404 - Page Not Found', 'color: #4361ee; font-size: 2em; font-weight: bold;'); function setLanguage() {
console.log('%cLooks like you\'re lost! Use the buttons above to find your way back.', 'color: #2b2d42; font-size: 1.1em;'); const userLanguage = navigator.language || navigator.userLanguage;
const isChinese = userLanguage.toLowerCase().includes('zh-cn');
// Simple parallax effect
document.addEventListener('mousemove', function(e) { if (isChinese) {
const container = document.querySelector('.container'); document.getElementById('page-title').textContent = '页面未找到 - 404';
const xAxis = (window.innerWidth / 2 - e.pageX) / 25; document.getElementById('heading').textContent = '页面未找到';
const yAxis = (window.innerHeight / 2 - e.pageY) / 25; document.getElementById('message').textContent = '您访问的页面可能已被移动、删除或暂时不可用。';
container.style.transform = `rotateY(${xAxis}deg) rotateX(${yAxis}deg)`; document.getElementById('home-btn').textContent = '返回首页';
}); document.getElementById('back-btn').textContent = '返回上一页';
</script>
console.log('%c404 - 页面未找到', 'color: #4361ee; font-size: 2em; font-weight: bold;');
console.log('%c您似乎迷路了但别担心点击上面的按钮可以找到回去的路。', 'color: #2b2d42; font-size: 1.1em;');
} else {
console.log('%c404 - Page Not Found', 'color: #4361ee; font-size: 2em; font-weight: bold;');
console.log('%cLooks like you\'re lost! Use the buttons above to find your way back.', 'color: #2b2d42; font-size: 1.1em;');
}
}
// Set language on page load
window.addEventListener('DOMContentLoaded', setLanguage);
// Simple parallax effect
document.addEventListener('mousemove', function(e) {
const container = document.querySelector('.container');
const xAxis = (window.innerWidth / 2 - e.pageX) / 25;
const yAxis = (window.innerHeight / 2 - e.pageY) / 25;
container.style.transform = `rotateY(${xAxis}deg) rotateX(${yAxis}deg)`;
});
</script>
</body> </body>
</html> </html>