1) 分片上传(routes/chunked.py) - POST /api/upload/init 建会话,校验表单/字段/扩展名/体积 - POST /api/upload/chunk 单片上传,幂等可重传,http body 直写磁盘 - GET /api/upload/status 查询已收分片 - POST /api/upload/complete 按序合并 + sha256 校验 + 清理分片 - /api/submit 新增 field fileTokens 挂载已上传文件(零拷贝 os.replace) - 过期会话(24h)由定时任务清理 2) 弱网下的样式可靠性 - Tailwind Play CDN / GSAP 改为本地自托管(static/js/vendor/) - vendor 资源 1 年 immutable 缓存,自家 css/js 1 小时 - CSS link 失败自动带 ?r= 重试一次 - status 页加关键内联样式兜底,极端情况下仍可读 3) 大文件落盘沿用流式写入(无 400MB 内存峰值)
412 lines
17 KiB
HTML
412 lines
17 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN" class="light">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>出错了 - 表单管理系统</title>
|
|
|
|
<!-- Tailwind CSS -->
|
|
<script src="/static/js/vendor/tailwind-play.js"></script>
|
|
<script>
|
|
tailwind.config = {
|
|
darkMode: 'class',
|
|
theme: {
|
|
extend: {
|
|
fontFamily: {
|
|
sans: ['Inter', 'sans-serif'],
|
|
serif: ['Playfair Display', 'serif'],
|
|
mono: ['SF Mono', 'monospace'],
|
|
},
|
|
colors: {
|
|
neutral: {
|
|
50: '#fafafa',
|
|
100: '#f5f5f5',
|
|
200: '#e5e5e5',
|
|
300: '#d4d4d4',
|
|
400: '#a3a3a3',
|
|
500: '#737373',
|
|
600: '#525252',
|
|
700: '#404040',
|
|
800: '#262626',
|
|
900: '#171717',
|
|
}
|
|
},
|
|
animation: {
|
|
'float': 'float 6s ease-in-out infinite',
|
|
'pulse-slow': 'pulse 4s cubic-bezier(0.4, 0, 0.6, 1) infinite',
|
|
'glitch': 'glitch 1s linear infinite',
|
|
},
|
|
keyframes: {
|
|
float: {
|
|
'0%, 100%': { transform: 'translateY(0px)' },
|
|
'50%': { transform: 'translateY(-20px)' },
|
|
},
|
|
glitch: {
|
|
'2%, 64%': { transform: 'translate(2px,0) skew(0deg)' },
|
|
'4%, 60%': { transform: 'translate(-2px,0) skew(0deg)' },
|
|
'62%': { transform: 'translate(0,0) skew(5deg)' },
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<!-- GSAP -->
|
|
<script src="/static/js/vendor/gsap.min.js"></script>
|
|
<script src="/static/js/particles.js"></script>
|
|
<link rel="stylesheet" href="/static/css/toast.css" onerror="this.onerror=null;this.href='/static/css/toast.css?r='+Date.now()">
|
|
<script src="/static/js/toast.js"></script>
|
|
<link rel="stylesheet" href="/static/css/basic.css" onerror="this.onerror=null;this.href='/static/css/basic.css?r='+Date.now()">
|
|
<link rel="stylesheet" href="/static/css/common.css" onerror="this.onerror=null;this.href='/static/css/common.css?r='+Date.now()">
|
|
<script src="/static/js/common.js"></script>
|
|
|
|
<style>
|
|
/* ── error 页面专属样式 ── */
|
|
body {
|
|
background-image:
|
|
radial-gradient(at 0% 0%, rgba(220, 38, 38, 0.03) 0px, transparent 50%),
|
|
radial-gradient(at 100% 100%, rgba(220, 38, 38, 0.03) 0px, transparent 50%);
|
|
}
|
|
|
|
.dark body {
|
|
background-image:
|
|
radial-gradient(at 0% 0%, rgba(239, 68, 68, 0.05) 0px, transparent 50%),
|
|
radial-gradient(at 100% 100%, rgba(239, 68, 68, 0.05) 0px, transparent 50%);
|
|
}
|
|
|
|
.error-code {
|
|
font-family: 'Playfair Display', serif;
|
|
font-size: clamp(120px, 20vw, 200px);
|
|
font-weight: 600;
|
|
line-height: 1;
|
|
background: linear-gradient(135deg, var(--error-text) 0%, #991b1b 100%);
|
|
-webkit-background-clip: text;
|
|
-webkit-text-fill-color: transparent;
|
|
background-clip: text;
|
|
opacity: 0.15;
|
|
position: absolute;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
z-index: 0;
|
|
pointer-events: none;
|
|
user-select: none;
|
|
}
|
|
|
|
.error-content {
|
|
position: relative;
|
|
z-index: 1;
|
|
}
|
|
|
|
.progress-ring {
|
|
transform: rotate(-90deg);
|
|
}
|
|
|
|
.progress-ring-circle {
|
|
transition: stroke-dashoffset 0.35s;
|
|
transform-origin: 50% 50%;
|
|
}
|
|
|
|
.btn-shine {
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.btn-shine::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: -100%;
|
|
width: 100%;
|
|
height: 100%;
|
|
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
|
|
transition: left 0.5s;
|
|
}
|
|
|
|
.btn-shine:hover::before {
|
|
left: 100%;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.error-code {
|
|
font-size: 100px;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body class="antialiased min-h-screen flex items-center justify-center relative">
|
|
|
|
<!-- Background Elements -->
|
|
<div class="fixed inset-0 overflow-hidden pointer-events-none">
|
|
<div class="absolute top-1/4 left-1/4 w-96 h-96 bg-red-500/5 rounded-full blur-3xl animate-pulse-slow"></div>
|
|
<div class="absolute bottom-1/4 right-1/4 w-96 h-96 bg-orange-500/5 rounded-full blur-3xl animate-pulse-slow"
|
|
style="animation-delay: 2s;"></div>
|
|
</div>
|
|
|
|
<!-- Main Content -->
|
|
<main class="relative w-full max-w-2xl mx-auto px-6 py-12">
|
|
|
|
<!-- Error Code Background -->
|
|
<div class="error-code" id="errorCodeBg">404</div>
|
|
|
|
<!-- Card -->
|
|
<div class="error-content glass rounded-3xl p-8 md:p-12 shadow-2xl theme-transition" id="mainCard">
|
|
|
|
<!-- Icon -->
|
|
<div class="w-20 h-20 mx-auto mb-8 rounded-2xl flex items-center justify-center theme-transition"
|
|
style="background-color: var(--error-bg); border: 1px solid var(--error-border);" id="iconContainer">
|
|
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"
|
|
style="color: var(--error-text);" id="errorIcon">
|
|
<circle cx="12" cy="12" r="10" />
|
|
<line x1="15" y1="9" x2="9" y2="15" />
|
|
<line x1="9" y1="9" x2="15" y2="15" />
|
|
</svg>
|
|
</div>
|
|
|
|
<!-- Title -->
|
|
<h1 class="font-serif text-3xl md:text-4xl font-medium text-center mb-4 tracking-tight theme-transition"
|
|
style="color: var(--text-primary);" id="errorTitle">
|
|
页面未找到
|
|
</h1>
|
|
|
|
<!-- Description -->
|
|
<p class="text-center mb-8 text-sm md:text-base leading-relaxed max-w-md mx-auto theme-transition"
|
|
style="color: var(--text-secondary);" id="errorDesc">
|
|
您访问的页面不存在或已被移除。请检查链接是否正确,或返回首页继续操作。
|
|
</p>
|
|
|
|
<!-- Error Details (Collapsible) -->
|
|
<div class="mb-8 rounded-xl overflow-hidden theme-transition"
|
|
style="background-color: var(--bg-primary); border: 1px solid var(--border-color);">
|
|
<button onclick="toggleDetails()"
|
|
class="w-full px-4 py-3 flex items-center justify-between text-xs font-medium uppercase tracking-wider theme-transition hover:opacity-70"
|
|
style="color: var(--text-muted);">
|
|
<span>技术详情</span>
|
|
<svg id="detailsArrow" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
|
stroke-width="2" class="transform transition-transform duration-300">
|
|
<polyline points="6 9 12 15 18 9"></polyline>
|
|
</svg>
|
|
</button>
|
|
<div id="errorDetails" class="hidden px-4 pb-4">
|
|
<div class="font-mono text-xs p-3 rounded-lg theme-transition"
|
|
style="background-color: var(--bg-secondary); color: var(--text-muted); border: 1px solid var(--border-color);">
|
|
<div class="mb-1"><span style="color: var(--error-text);">Status:</span> <span
|
|
id="detailStatus">404 Not Found</span></div>
|
|
<div class="mb-1"><span style="color: var(--error-text);">Path:</span> <span
|
|
id="detailPath">/unknown</span></div>
|
|
<div><span style="color: var(--error-text);">Time:</span> <span id="detailTime">2024-01-01
|
|
00:00:00</span></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Countdown Timer -->
|
|
<div class="flex items-center justify-center gap-4 mb-8">
|
|
<div class="relative w-16 h-16">
|
|
<svg class="progress-ring w-16 h-16">
|
|
<circle class="progress-ring-circle" stroke="currentColor" stroke-width="3" fill="transparent"
|
|
r="28" cx="32" cy="32" style="color: var(--border-color); opacity: 0.3;" />
|
|
<circle class="progress-ring-circle" stroke="currentColor" stroke-width="3" fill="transparent"
|
|
r="28" cx="32" cy="32" style="color: var(--error-text);" id="progressCircle" />
|
|
</svg>
|
|
<div class="absolute inset-0 flex items-center justify-center font-mono text-lg font-semibold theme-transition"
|
|
style="color: var(--text-primary);" id="countdown">5</div>
|
|
</div>
|
|
<div class="text-sm theme-transition" style="color: var(--text-muted);">
|
|
秒后自动返回首页
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Action Buttons -->
|
|
<div class="flex flex-col sm:flex-row gap-3 justify-center">
|
|
<a href="/" id="homeBtn"
|
|
class="btn-shine px-8 py-3 rounded-full text-sm font-medium tracking-wide text-center transform hover:scale-[1.02] active:scale-[0.98] transition-all theme-transition"
|
|
style="background-color: var(--accent-bg); color: var(--accent-text);">
|
|
立即返回首页
|
|
</a>
|
|
<button onclick="history.back()"
|
|
class="px-8 py-3 rounded-full text-sm font-medium tracking-wide text-center transform hover:scale-[1.02] active:scale-[0.98] transition-all theme-transition"
|
|
style="background-color: var(--bg-primary); color: var(--text-secondary); border: 1px solid var(--border-color);">
|
|
返回上一页
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Footer -->
|
|
<div class="mt-8 text-center">
|
|
<p class="text-[10px] tracking-[0.3em] uppercase font-medium theme-transition"
|
|
style="color: var(--text-muted);">
|
|
Form Admin System
|
|
</p>
|
|
</div>
|
|
</main>
|
|
|
|
<script>
|
|
// Parse URL Parameters for Error Info
|
|
function parseErrorInfo() {
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
const code = urlParams.get('code') || '404';
|
|
const redirect = urlParams.get('redirect');
|
|
const message = urlParams.get('message') || '';
|
|
const path = window.location.pathname;
|
|
|
|
// Error configurations
|
|
const errorConfigs = {
|
|
'404': {
|
|
title: '页面未找到',
|
|
desc: '您访问的页面不存在或已被移除。请检查链接是否正确,或返回首页继续操作。',
|
|
icon: `<circle cx="12" cy="12" r="10"/><line x1="15" y1="9" x2="9" y2="15"/><line x1="9" y1="9" x2="15" y2="15"/>`
|
|
},
|
|
'403': {
|
|
title: '访问被拒绝',
|
|
desc: '您没有权限访问此页面。如需帮助,请联系系统管理员。',
|
|
icon: `<path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/>`
|
|
},
|
|
'500': {
|
|
title: '服务器错误',
|
|
desc: '服务器遇到了意外情况,无法完成您的请求。请稍后再试。',
|
|
icon: `<polygon points="12 2 2 7 12 12 22 7 12 2"/><polyline points="2 17 12 22 22 17"/><polyline points="2 12 12 17 22 12"/>`
|
|
},
|
|
'401': {
|
|
title: '未授权',
|
|
desc: '您需要先登录才能访问此页面。即将跳转到登录页面。',
|
|
icon: `<path d="M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4"/><polyline points="10 17 15 12 10 7"/><line x1="15" y1="12" x2="3" y2="12"/>`
|
|
}
|
|
};
|
|
|
|
const config = errorConfigs[code] || errorConfigs['404'];
|
|
|
|
// Update DOM
|
|
document.getElementById('errorCodeBg').textContent = code;
|
|
document.getElementById('errorTitle').textContent = message || config.title;
|
|
//document.getElementById('errorDesc').textContent = config.desc;
|
|
document.getElementById('errorIcon').innerHTML = config.icon;
|
|
document.getElementById('detailStatus').textContent = code + ' ' + (config.title === '页面未找到' ? 'Not Found' : config.title);
|
|
document.getElementById('detailPath').textContent = path;
|
|
document.getElementById('detailTime').textContent = new Date().toLocaleString('zh-CN');
|
|
const description = urlParams.get('description');
|
|
if (description) {
|
|
document.getElementById('errorDesc').textContent = decodeURIComponent(description);
|
|
}
|
|
|
|
// Update redirect target for 401
|
|
if (code === '401') {
|
|
document.getElementById('homeBtn').href = '/login?redirect=' + encodeURIComponent(path);
|
|
}
|
|
// 设置首页按钮行为
|
|
const homeBtn = document.getElementById('homeBtn');
|
|
if (code === '401') {
|
|
homeBtn.href = '/login'; // 401 直接回登录,不带任何参数
|
|
homeBtn.textContent = '去登录';
|
|
} else if (redirect) {
|
|
homeBtn.href = redirect; // 其他错误,有指定回跳就回指定页面
|
|
} else {
|
|
homeBtn.href = '/'; // 默认回首页
|
|
}
|
|
|
|
return code;
|
|
}
|
|
|
|
// Toggle Details
|
|
function toggleDetails() {
|
|
const details = document.getElementById('errorDetails');
|
|
const arrow = document.getElementById('detailsArrow');
|
|
details.classList.toggle('hidden');
|
|
arrow.style.transform = details.classList.contains('hidden') ? 'rotate(0deg)' : 'rotate(180deg)';
|
|
}
|
|
|
|
// Countdown Logic
|
|
let countdown = 5;
|
|
const circle = document.getElementById('progressCircle');
|
|
const radius = circle.r.baseVal.value;
|
|
const circumference = radius * 2 * Math.PI;
|
|
|
|
circle.style.strokeDasharray = `${circumference} ${circumference}`;
|
|
circle.style.strokeDashoffset = circumference;
|
|
|
|
function setProgress(percent) {
|
|
const offset = circumference - percent / 100 * circumference;
|
|
circle.style.strokeDashoffset = offset;
|
|
}
|
|
|
|
function startCountdown() {
|
|
const timer = setInterval(() => {
|
|
countdown--;
|
|
document.getElementById('countdown').textContent = countdown;
|
|
setProgress((5 - countdown) / 5 * 100);
|
|
|
|
if (countdown <= 0) {
|
|
clearInterval(timer);
|
|
const code = document.getElementById('errorCodeBg').textContent;
|
|
if (code === '401') {
|
|
window.location.href = '/login?redirect=' + encodeURIComponent(window.location.pathname);
|
|
} else {
|
|
window.location.href = '/';
|
|
}
|
|
}
|
|
}, 1000);
|
|
}
|
|
|
|
// Animations
|
|
window.addEventListener('load', () => {
|
|
parseErrorInfo();
|
|
|
|
// Animate card entrance
|
|
gsap.from("#mainCard", {
|
|
y: 30,
|
|
opacity: 0,
|
|
duration: 0.8,
|
|
ease: "power2.out"
|
|
});
|
|
|
|
gsap.from("#iconContainer", {
|
|
scale: 0,
|
|
rotation: -180,
|
|
duration: 0.6,
|
|
delay: 0.2,
|
|
ease: "back.out(1.7)"
|
|
});
|
|
|
|
gsap.from("#errorTitle", {
|
|
y: 20,
|
|
opacity: 0,
|
|
duration: 0.6,
|
|
delay: 0.3,
|
|
ease: "power2.out"
|
|
});
|
|
|
|
gsap.from("#errorDesc", {
|
|
y: 20,
|
|
opacity: 0,
|
|
duration: 0.6,
|
|
delay: 0.4,
|
|
ease: "power2.out"
|
|
});
|
|
|
|
// Start countdown after animation
|
|
setTimeout(startCountdown, 1000);
|
|
});
|
|
|
|
// Hover effect for error code
|
|
document.getElementById('errorCodeBg').addEventListener('mouseenter', function () {
|
|
gsap.to(this, {
|
|
scale: 1.1,
|
|
opacity: 0.2,
|
|
duration: 0.3
|
|
});
|
|
});
|
|
|
|
document.getElementById('errorCodeBg').addEventListener('mouseleave', function () {
|
|
gsap.to(this, {
|
|
scale: 1,
|
|
opacity: 0.15,
|
|
duration: 0.3
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html> |