feat(nginx): 为 37point2.cn 网站的 404 页面添加多语言支持
- 添加简体中文和英文的内容切换 - 根据用户浏览器语言自动设置页面内容 - 更新页面标题、标题、消息内容和按钮文本 - 保持原有的页面样式和交互效果
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="auto">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<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>
|
||||
:root {
|
||||
--primary-color: #4361ee;
|
||||
@@ -12,13 +12,13 @@
|
||||
--bg-color: #f8f9fa;
|
||||
--error-color: #ef233c;
|
||||
}
|
||||
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
|
||||
background-color: var(--bg-color);
|
||||
@@ -32,12 +32,12 @@
|
||||
padding: 2rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
.container {
|
||||
max-width: 600px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
||||
.error-code {
|
||||
font-size: 8rem;
|
||||
font-weight: 800;
|
||||
@@ -46,7 +46,7 @@
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
|
||||
.error-code::after {
|
||||
content: '404';
|
||||
position: absolute;
|
||||
@@ -56,26 +56,26 @@
|
||||
z-index: -1;
|
||||
transform: scale(1.5);
|
||||
}
|
||||
|
||||
|
||||
h1 {
|
||||
font-size: 2.5rem;
|
||||
margin-bottom: 1rem;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
|
||||
p {
|
||||
font-size: 1.1rem;
|
||||
margin-bottom: 2rem;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 1rem;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
|
||||
.btn {
|
||||
display: inline-block;
|
||||
padding: 0.8rem 1.8rem;
|
||||
@@ -86,33 +86,33 @@
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
.btn-primary {
|
||||
background-color: var(--primary-color);
|
||||
color: white;
|
||||
}
|
||||
|
||||
|
||||
.btn-primary:hover {
|
||||
background-color: var(--secondary-color);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 5px 15px rgba(67, 97, 238, 0.3);
|
||||
}
|
||||
|
||||
|
||||
.btn-secondary {
|
||||
background-color: transparent;
|
||||
color: var(--primary-color);
|
||||
border: 2px solid var(--primary-color);
|
||||
}
|
||||
|
||||
|
||||
.btn-secondary:hover {
|
||||
background-color: rgba(67, 97, 238, 0.1);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
|
||||
.animation {
|
||||
animation: float 6s ease-in-out infinite;
|
||||
}
|
||||
|
||||
|
||||
@keyframes float {
|
||||
0%, 100% {
|
||||
transform: translateY(0);
|
||||
@@ -121,12 +121,12 @@
|
||||
transform: translateY(-20px);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.error-code {
|
||||
font-size: 6rem;
|
||||
}
|
||||
|
||||
|
||||
h1 {
|
||||
font-size: 2rem;
|
||||
}
|
||||
@@ -134,28 +134,47 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="error-code animation">404</div>
|
||||
<h1>Page Not Found</h1>
|
||||
<p>The page you're looking for might have been moved, deleted, or doesn't exist.</p>
|
||||
<div class="actions">
|
||||
<a href="/" class="btn btn-primary">Go to Homepage</a>
|
||||
<a href="javascript:history.back()" class="btn btn-secondary">Go Back</a>
|
||||
<div class="container">
|
||||
<div class="error-code animation">404</div>
|
||||
<h1 id="heading">Page Not Found</h1>
|
||||
<p id="message">The page you're looking for might have been moved, deleted, or doesn't exist.</p>
|
||||
<div class="actions">
|
||||
<a href="/" class="btn btn-primary" id="home-btn">Go to Homepage</a>
|
||||
<a href="javascript:history.back()" class="btn btn-secondary" id="back-btn">Go Back</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Console message
|
||||
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;');
|
||||
|
||||
// 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>
|
||||
<script>
|
||||
// Language detection and content switching
|
||||
function setLanguage() {
|
||||
const userLanguage = navigator.language || navigator.userLanguage;
|
||||
const isChinese = userLanguage.toLowerCase().includes('zh-cn');
|
||||
|
||||
if (isChinese) {
|
||||
document.getElementById('page-title').textContent = '页面未找到 - 404';
|
||||
document.getElementById('heading').textContent = '页面未找到';
|
||||
document.getElementById('message').textContent = '您访问的页面可能已被移动、删除或暂时不可用。';
|
||||
document.getElementById('home-btn').textContent = '返回首页';
|
||||
document.getElementById('back-btn').textContent = '返回上一页';
|
||||
|
||||
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>
|
||||
</html>
|
||||
Reference in New Issue
Block a user