初版:上传接口(从线上实例导出,适配容器端口)
This commit is contained in:
@@ -0,0 +1,562 @@
|
||||
<!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>502 Bad Gateway</title>
|
||||
|
||||
<!-- Tailwind CSS (CDN) -->
|
||||
<script src="https://cdn.tailwindcss.com"></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 (CDN) -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
||||
|
||||
<!-- 鍐呰仈 CSS锛圕SS 鍙橀噺 + 涓撳睘鏍峰紡锛?-->
|
||||
<style>
|
||||
/* ========== CSS 鍙橀噺锛堢户鎵胯嚜鍘熺郴缁燂級 ========== */
|
||||
:root {
|
||||
--bg-primary: #fafafa;
|
||||
--bg-secondary: #ffffff;
|
||||
--text-primary: #171717;
|
||||
--text-secondary: #525252;
|
||||
--text-muted: #737373;
|
||||
--border-color: #e5e5e5;
|
||||
--accent-bg: #171717;
|
||||
--accent-text: #ffffff;
|
||||
--glass-bg: rgba(255, 255, 255, 0.7);
|
||||
--glass-border: rgba(255, 255, 255, 0.5);
|
||||
--glass-hover: rgba(255, 255, 255, 0.9);
|
||||
--shadow-color: rgba(0, 0, 0, 0.05);
|
||||
--error-bg: #fef2f2;
|
||||
--error-border: #fee2e2;
|
||||
--error-text: #dc2626;
|
||||
--warning-bg: #fffbeb;
|
||||
--warning-border: #fef3c7;
|
||||
--warning-text: #d97706;
|
||||
}
|
||||
|
||||
.dark {
|
||||
--bg-primary: #0a0a0a;
|
||||
--bg-secondary: #171717;
|
||||
--text-primary: #fafafa;
|
||||
--text-secondary: #a3a3a3;
|
||||
--text-muted: #737373;
|
||||
--border-color: #262626;
|
||||
--accent-bg: #fafafa;
|
||||
--accent-text: #171717;
|
||||
--glass-bg: rgba(23, 23, 23, 0.8);
|
||||
--glass-border: rgba(255, 255, 255, 0.1);
|
||||
--glass-hover: rgba(38, 38, 38, 0.9);
|
||||
--shadow-color: rgba(0, 0, 0, 0.5);
|
||||
--error-bg: rgba(220, 38, 38, 0.1);
|
||||
--error-border: rgba(220, 38, 38, 0.2);
|
||||
--error-text: #ef4444;
|
||||
--warning-bg: rgba(217, 119, 6, 0.1);
|
||||
--warning-border: rgba(217, 119, 6, 0.2);
|
||||
--warning-text: #fbbf24;
|
||||
}
|
||||
|
||||
/* ========== 鍏ㄥ眬閲嶇疆 ========== */
|
||||
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
|
||||
html { scroll-behavior: smooth; }
|
||||
::selection { background: rgba(128, 128, 128, 0.2); color: var(--text-primary); }
|
||||
|
||||
body {
|
||||
font-family: 'Inter', sans-serif;
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
overflow-x: hidden;
|
||||
transition: background-color 0.5s ease, color 0.5s ease;
|
||||
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%);
|
||||
background-color: var(--bg-primary);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
html.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%);
|
||||
}
|
||||
|
||||
.font-serif {
|
||||
font-family: 'Playfair Display', serif;
|
||||
}
|
||||
|
||||
.glass {
|
||||
background: var(--glass-bg);
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
border: 1px solid var(--glass-border);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
.glass:hover { background: var(--glass-hover); }
|
||||
|
||||
.theme-transition {
|
||||
transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
|
||||
}
|
||||
|
||||
.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%; }
|
||||
|
||||
/* 鈹€鈹€ 502 澶у彿鑳屾櫙鏁板瓧 鈹€鈹€ */
|
||||
.error-code {
|
||||
font-family: 'Playfair Display', serif;
|
||||
font-size: clamp(120px, 20vw, 200px);
|
||||
font-weight: 600;
|
||||
line-height: 1;
|
||||
background: linear-gradient(135deg, var(--warning-text) 0%, #b45309 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%;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.error-code { font-size: 100px; }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="antialiased min-h-screen flex items-center justify-center relative">
|
||||
|
||||
<!-- 鑳屾櫙鍏夋檿 -->
|
||||
<div class="fixed inset-0 overflow-hidden pointer-events-none">
|
||||
<div class="absolute top-1/4 left-1/4 w-96 h-96 rounded-full blur-3xl animate-pulse-slow"
|
||||
style="background: rgba(217,119,6,0.06);"></div>
|
||||
<div class="absolute bottom-1/4 right-1/4 w-96 h-96 rounded-full blur-3xl animate-pulse-slow"
|
||||
style="background: rgba(220,38,38,0.05); 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">502</div>
|
||||
|
||||
<!-- Card -->
|
||||
<div class="error-content glass rounded-3xl p-8 md:p-12 shadow-2xl theme-transition" id="mainCard">
|
||||
|
||||
<!-- Icon 鈥?502 缃戝叧鏂紑鍥炬爣 -->
|
||||
<div class="w-20 h-20 mx-auto mb-8 rounded-2xl flex items-center justify-center theme-transition"
|
||||
style="background-color: var(--warning-bg); border: 1px solid var(--warning-border);" id="iconContainer">
|
||||
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"
|
||||
style="color: var(--warning-text);" id="errorIcon">
|
||||
<!-- 鏂紑杩炴帴鍥炬爣锛氫袱鏈嶅姟鍣ㄤ腑闂存柇绾?-->
|
||||
<rect x="2" y="6" width="6" height="12" rx="1" />
|
||||
<rect x="16" y="6" width="6" height="12" rx="1" />
|
||||
<line x1="8" y1="12" x2="16" y2="12" stroke-dasharray="2 3" />
|
||||
<line x1="8" y1="12" x2="16" y2="12" stroke-width="2" stroke="#ef4444" opacity="0.5" />
|
||||
</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">
|
||||
502 Bad Gateway<br>缃戝叧杩炴帴澶辫触
|
||||
</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(--warning-text);">Status:</span> <span id="detailStatus">502 Bad Gateway</span></div>
|
||||
<div class="mb-1"><span style="color: var(--warning-text);">Path:</span> <span id="detailPath">/</span></div>
|
||||
<div><span style="color: var(--warning-text);">Time:</span> <span id="detailTime">--</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Action Buttons -->
|
||||
<div class="flex flex-col sm:flex-row gap-3 justify-center">
|
||||
<button onclick="refreshPage()"
|
||||
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); cursor: pointer; border: none;">
|
||||
绔嬪嵆鍒锋柊椤甸潰
|
||||
</button>
|
||||
<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); cursor: pointer;">
|
||||
杩斿洖涓婁竴椤? </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);">
|
||||
|
||||
</p>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
// ============================================================
|
||||
// 绮掑瓙绯荤粺 鈥?鍐呰仈鑷?particles.js锛堝畬鏁村唴宓岋紝鏃犲閮ㄤ緷璧栵級
|
||||
// ============================================================
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
class ParticleSystem {
|
||||
constructor(options = {}) {
|
||||
this.canvas = null;
|
||||
this.ctx = null;
|
||||
this.particles = [];
|
||||
this.animationId = null;
|
||||
|
||||
this.config = {
|
||||
particleCount: options.particleCount || null,
|
||||
connectionDistance: options.connectionDistance || 100,
|
||||
mouseDistance: options.mouseDistance || 120,
|
||||
attractStrength: options.attractStrength || 0.04,
|
||||
speed: options.speed || 0.4,
|
||||
size: { min: 2, max: 4 },
|
||||
opacity: { min: 0.3, max: 0.6 },
|
||||
zIndex: options.zIndex || -1,
|
||||
colorLight: '100, 100, 100',
|
||||
colorDark: '150, 150, 150',
|
||||
lineOpacity: 0.2,
|
||||
maxConnections: 5,
|
||||
bgColor: options.bgColor || null
|
||||
};
|
||||
|
||||
this.mouse = { x: null, y: null, active: false };
|
||||
this.isDark = false;
|
||||
this.dpr = window.devicePixelRatio || 1;
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
init() {
|
||||
if (document.getElementById('particleCanvas')) return;
|
||||
this.canvas = document.createElement('canvas');
|
||||
this.canvas.id = 'particleCanvas';
|
||||
this.canvas.style.cssText = [
|
||||
'position: fixed',
|
||||
'top: 0',
|
||||
'left: 0',
|
||||
'width: 100%',
|
||||
'height: 100%',
|
||||
'z-index: ' + this.config.zIndex,
|
||||
'pointer-events: none',
|
||||
'touch-action: none',
|
||||
'opacity: 0.6'
|
||||
].join(';');
|
||||
document.body.insertBefore(this.canvas, document.body.firstChild);
|
||||
this.ctx = this.canvas.getContext('2d', { alpha: true });
|
||||
this.resize();
|
||||
window.addEventListener('resize', () => this.resize(), { passive: true });
|
||||
this.initEvents();
|
||||
this.initThemeListener();
|
||||
this.createParticles();
|
||||
this.animate();
|
||||
}
|
||||
|
||||
initEvents() {
|
||||
var self = this;
|
||||
var updateMouse = function(x, y) {
|
||||
self.mouse.x = x; self.mouse.y = y; self.mouse.active = true;
|
||||
clearTimeout(self.mouseTimer);
|
||||
self.mouseTimer = setTimeout(function() { self.mouse.active = false; }, 100);
|
||||
};
|
||||
window.addEventListener('mousemove', function(e) {
|
||||
updateMouse(e.clientX, e.clientY);
|
||||
}, { passive: true });
|
||||
window.addEventListener('touchstart', function(e) {
|
||||
if (e.touches[0]) updateMouse(e.touches[0].clientX, e.touches[0].clientY);
|
||||
}, { passive: true });
|
||||
window.addEventListener('touchmove', function(e) {
|
||||
if (e.touches[0]) updateMouse(e.touches[0].clientX, e.touches[0].clientY);
|
||||
}, { passive: true });
|
||||
window.addEventListener('touchend', function() { self.mouse.active = false; });
|
||||
}
|
||||
|
||||
resize() {
|
||||
this.width = window.innerWidth;
|
||||
this.height = window.innerHeight;
|
||||
this.canvas.width = this.width * this.dpr;
|
||||
this.canvas.height = this.height * this.dpr;
|
||||
this.canvas.style.width = this.width + 'px';
|
||||
this.canvas.style.height = this.height + 'px';
|
||||
this.ctx.scale(this.dpr, this.dpr);
|
||||
if (!this.config.particleCount) {
|
||||
var area = this.width * this.height;
|
||||
this.targetCount = Math.min(Math.max(Math.floor(area / 20000), 40), 100);
|
||||
}
|
||||
}
|
||||
|
||||
initThemeListener() {
|
||||
var self = this;
|
||||
this.checkTheme();
|
||||
var mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
mediaQuery.addEventListener('change', function() { self.checkTheme(); });
|
||||
var observer = new MutationObserver(function() { self.checkTheme(); });
|
||||
observer.observe(document.documentElement, { attributes: true, attributeFilter: ['class', 'data-theme'] });
|
||||
}
|
||||
|
||||
checkTheme() {
|
||||
var html = document.documentElement;
|
||||
this.isDark = html.classList.contains('dark') ||
|
||||
html.getAttribute('data-theme') === 'dark' ||
|
||||
(!html.classList.contains('light') && window.matchMedia('(prefers-color-scheme: dark)').matches);
|
||||
}
|
||||
|
||||
createParticles() {
|
||||
var count = this.config.particleCount || this.targetCount || 60;
|
||||
this.particles = [];
|
||||
for (var i = 0; i < count; i++) {
|
||||
this.particles.push({
|
||||
x: Math.random() * this.width,
|
||||
y: Math.random() * this.height,
|
||||
vx: (Math.random() - 0.75) * this.config.speed,
|
||||
vy: (Math.random() - 0.75) * this.config.speed,
|
||||
size: Math.random() * (this.config.size.max - this.config.size.min) + this.config.size.min,
|
||||
opacity: Math.random() * (this.config.opacity.max - this.config.opacity.min) + this.config.opacity.min,
|
||||
phase: Math.random() * Math.PI * 2,
|
||||
phaseSpeed: 0.02 + Math.random() * 0.02
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
updateParticle(p) {
|
||||
p.phase += p.phaseSpeed;
|
||||
var waveX = Math.sin(p.phase) * 0.1;
|
||||
var waveY = Math.cos(p.phase * 0.7) * 0.1;
|
||||
p.x += p.vx + waveX;
|
||||
p.y += p.vy + waveY;
|
||||
if (this.mouse.active && this.mouse.x !== null) {
|
||||
var dx = this.mouse.x - p.x;
|
||||
var dy = this.mouse.y - p.y;
|
||||
var dist = Math.sqrt(dx * dx + dy * dy);
|
||||
if (dist < this.config.mouseDistance) {
|
||||
var force = (1 - dist / this.config.mouseDistance) * this.config.attractStrength;
|
||||
p.vx += dx * force * 0.01;
|
||||
p.vy += dy * force * 0.01;
|
||||
}
|
||||
}
|
||||
var maxSpeed = this.config.speed * 1.5;
|
||||
p.vx = Math.max(-maxSpeed, Math.min(maxSpeed, p.vx));
|
||||
p.vy = Math.max(-maxSpeed, Math.min(maxSpeed, p.vy));
|
||||
p.vx *= 0.995;
|
||||
p.vy *= 0.995;
|
||||
var margin = 50;
|
||||
if (p.x < -margin) p.x = this.width + margin;
|
||||
if (p.x > this.width + margin) p.x = -margin;
|
||||
if (p.y < -margin) p.y = this.height + margin;
|
||||
if (p.y > this.height + margin) p.y = -margin;
|
||||
}
|
||||
|
||||
draw() {
|
||||
var color = this.isDark ? this.config.colorDark : this.config.colorLight;
|
||||
this.drawConnections(color);
|
||||
for (var i = 0; i < this.particles.length; i++) {
|
||||
var p = this.particles[i];
|
||||
this.ctx.beginPath();
|
||||
this.ctx.arc(p.x, p.y, p.size, 0, Math.PI * 2);
|
||||
this.ctx.fillStyle = 'rgba(' + color + ', ' + p.opacity + ')';
|
||||
this.ctx.fill();
|
||||
}
|
||||
}
|
||||
|
||||
drawConnections(color) {
|
||||
for (var i = 0; i < this.particles.length; i++) {
|
||||
var connections = 0;
|
||||
var p1 = this.particles[i];
|
||||
for (var j = i + 1; j < Math.min(i + 20, this.particles.length); j++) {
|
||||
if (connections >= this.config.maxConnections) break;
|
||||
var p2 = this.particles[j];
|
||||
var dx = p1.x - p2.x;
|
||||
var dy = p1.y - p2.y;
|
||||
var distSq = dx * dx + dy * dy;
|
||||
if (distSq < this.config.connectionDistance * this.config.connectionDistance) {
|
||||
var dist = Math.sqrt(distSq);
|
||||
var opacity = this.config.lineOpacity * (1 - dist / this.config.connectionDistance);
|
||||
this.ctx.beginPath();
|
||||
this.ctx.moveTo(p1.x, p1.y);
|
||||
this.ctx.lineTo(p2.x, p2.y);
|
||||
this.ctx.strokeStyle = 'rgba(' + color + ', ' + opacity + ')';
|
||||
this.ctx.lineWidth = 0.5;
|
||||
this.ctx.stroke();
|
||||
connections++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
animate() {
|
||||
var self = this;
|
||||
this.ctx.clearRect(0, 0, this.width, this.height);
|
||||
for (var i = 0; i < this.particles.length; i++) {
|
||||
this.updateParticle(this.particles[i]);
|
||||
}
|
||||
this.draw();
|
||||
this.animationId = requestAnimationFrame(function() { self.animate(); });
|
||||
}
|
||||
|
||||
destroy() {
|
||||
if (this.animationId) cancelAnimationFrame(this.animationId);
|
||||
if (this.canvas && this.canvas.parentNode) {
|
||||
this.canvas.parentNode.removeChild(this.canvas);
|
||||
}
|
||||
window.particleSystem = null;
|
||||
}
|
||||
}
|
||||
|
||||
function autoInit() {
|
||||
if (document.body && document.body.hasAttribute('data-no-particles')) return;
|
||||
if (window.particleSystem) return;
|
||||
if (!document.body) { setTimeout(autoInit, 100); return; }
|
||||
window.particleSystem = new ParticleSystem();
|
||||
}
|
||||
|
||||
window.ParticleSystem = ParticleSystem;
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', autoInit);
|
||||
} else {
|
||||
setTimeout(autoInit, 0);
|
||||
}
|
||||
})();
|
||||
|
||||
// ============================================================
|
||||
// 椤甸潰閫昏緫
|
||||
// ============================================================
|
||||
|
||||
// Toggle 鎶€鏈鎯? function toggleDetails() {
|
||||
var details = document.getElementById('errorDetails');
|
||||
var arrow = document.getElementById('detailsArrow');
|
||||
details.classList.toggle('hidden');
|
||||
arrow.style.transform = details.classList.contains('hidden') ? 'rotate(0deg)' : 'rotate(180deg)';
|
||||
}
|
||||
|
||||
// 鍒锋柊椤甸潰
|
||||
function refreshPage() {
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 涓婚鑷姩璺熼殢绯荤粺
|
||||
// ============================================================
|
||||
(function() {
|
||||
var html = document.documentElement;
|
||||
function applyTheme() {
|
||||
var dark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
html.classList.toggle('dark', dark);
|
||||
}
|
||||
applyTheme();
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', applyTheme);
|
||||
})();
|
||||
|
||||
// GSAP 鍏ュ満鍔ㄧ敾
|
||||
window.addEventListener('load', function() {
|
||||
// 鏇存柊鏃堕棿
|
||||
document.getElementById('detailTime').textContent = new Date().toLocaleString('zh-CN');
|
||||
|
||||
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" });
|
||||
|
||||
});
|
||||
|
||||
// 鑳屾櫙鏁板瓧 hover 鏁堟灉
|
||||
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>
|
||||
@@ -0,0 +1,504 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN" class="light">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<title>管理后台</title>
|
||||
|
||||
<!-- Tailwind CSS -->
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<script>
|
||||
tailwind.config = {
|
||||
darkMode: 'class',
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
neutral: {
|
||||
50: '#fafafa',
|
||||
100: '#f5f5f5',
|
||||
200: '#e5e5e5',
|
||||
300: '#d4d4d4',
|
||||
400: '#a3a3a3',
|
||||
500: '#737373',
|
||||
600: '#525252',
|
||||
700: '#404040',
|
||||
800: '#262626',
|
||||
900: '#171717',
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- GSAP for animations -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
||||
<script src="/static/js/particles.js"></script>
|
||||
<link rel="stylesheet" href="/static/css/toast.css">
|
||||
<script src="/static/js/toast.js"></script>
|
||||
<link rel="stylesheet" href="/static/css/basic.css">
|
||||
<link rel="stylesheet" href="/static/css/common.css">
|
||||
<script src="/static/js/common.js"></script>
|
||||
|
||||
<style>
|
||||
/* ── admin 页面专属样式 ── */
|
||||
.form-card {
|
||||
background: var(--glass-bg);
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
border: 1px solid var(--glass-border);
|
||||
border-radius: 24px;
|
||||
padding: 24px;
|
||||
transition: all 0.4s cubic-bezier(0.2, 0, 0, 1);
|
||||
opacity: 0;
|
||||
transform: translateY(20px);
|
||||
}
|
||||
|
||||
.form-card:hover {
|
||||
transform: translateY(-4px);
|
||||
box-shadow: 0 20px 40px -15px var(--shadow-color);
|
||||
border-color: rgba(128, 128, 128, 0.3);
|
||||
background: var(--glass-hover);
|
||||
}
|
||||
|
||||
.btn-manage {
|
||||
background-color: rgba(99, 102, 241, 0.1);
|
||||
color: #6366f1;
|
||||
border: 1px solid rgba(99, 102, 241, 0.2);
|
||||
}
|
||||
|
||||
.btn-manage:hover {
|
||||
background-color: rgba(99, 102, 241, 0.2);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.quick-action {
|
||||
background: var(--glass-bg);
|
||||
border: 1px solid var(--glass-border);
|
||||
border-radius: 16px;
|
||||
padding: 20px;
|
||||
transition: all 0.3s ease;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.quick-action:hover {
|
||||
background: var(--glass-hover);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 10px 20px -10px var(--shadow-color);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="antialiased min-h-screen relative">
|
||||
|
||||
<!-- Progress Bar -->
|
||||
<div class="fixed top-0 left-0 w-full h-[2px] z-50 theme-transition" style="background-color: var(--border-color);">
|
||||
<div id="scrollProgress" class="h-full w-0 transition-all duration-100 ease-out"></div>
|
||||
</div>
|
||||
|
||||
<!-- Header -->
|
||||
<header class="fixed top-0 w-full z-40 px-4 sm:px-6 py-4 sm:py-5 glass theme-transition border-b">
|
||||
<div class="max-w-6xl mx-auto flex justify-between items-center">
|
||||
<!-- 左侧:Logo / 页面标识 -->
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="flex items-center gap-2">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none"
|
||||
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"
|
||||
style="color:var(--text-primary)">
|
||||
<rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/>
|
||||
<rect x="14" y="14" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/>
|
||||
</svg>
|
||||
<h1 class="font-serif text-lg sm:text-xl font-semibold tracking-tight theme-transition"
|
||||
style="color: var(--text-primary);">Admin</h1>
|
||||
</div>
|
||||
<span class="hidden sm:inline text-[10px] tracking-[0.2em] uppercase font-medium theme-transition"
|
||||
style="color: var(--text-muted);">管理后台</span>
|
||||
</div>
|
||||
|
||||
<!-- 右侧:退出登录 -->
|
||||
<div class="flex items-center gap-2 sm:gap-3">
|
||||
<button onclick="logout()" class="btn btn-secondary px-4 py-2.5 rounded-full text-xs sm:text-sm font-medium tracking-wide flex items-center gap-2">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/>
|
||||
<polyline points="16 17 21 12 16 7"/>
|
||||
<line x1="21" y1="12" x2="9" y2="12"/>
|
||||
</svg>
|
||||
<span class="hidden sm:inline">退出登录</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="relative pt-32 pb-24 px-6">
|
||||
<div class="max-w-6xl mx-auto">
|
||||
|
||||
<!-- Header Section -->
|
||||
<div class="mb-12 opacity-0" id="headerSection">
|
||||
<h2 class="font-serif text-4xl sm:text-5xl leading-[1.1] font-medium tracking-tight mb-4 theme-transition"
|
||||
style="color: var(--text-primary);">
|
||||
管理后台
|
||||
</h2>
|
||||
<p class="text-sm leading-relaxed max-w-md tracking-wide font-light theme-transition"
|
||||
style="color: var(--text-secondary);">
|
||||
创建和管理表单,查看提交状态,管理用户权限。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Quick Actions -->
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-12">
|
||||
<a href="/create" class="quick-action stagger-item group">
|
||||
<div class="w-12 h-12 rounded-xl flex items-center justify-center mb-4 theme-transition"
|
||||
style="background: var(--bg-primary);">
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
|
||||
class="theme-transition group-hover:scale-110 transition-transform" style="color: var(--text-primary);">
|
||||
<line x1="12" y1="5" x2="12" y2="19"></line>
|
||||
<line x1="5" y1="12" x2="19" y2="12"></line>
|
||||
</svg>
|
||||
</div>
|
||||
<h3 class="font-medium text-base mb-1 theme-transition" style="color: var(--text-primary);">新建表单</h3>
|
||||
<p class="text-xs theme-transition" style="color: var(--text-muted);">创建数据收集表单</p>
|
||||
</a>
|
||||
|
||||
<a href="/preset_manage" class="quick-action stagger-item group">
|
||||
<div class="w-12 h-12 rounded-xl flex items-center justify-center mb-4 theme-transition"
|
||||
style="background: var(--info-bg);">
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
|
||||
class="theme-transition group-hover:scale-110 transition-transform" style="color: var(--info-text);">
|
||||
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
|
||||
<polyline points="14 2 14 8 20 8"></polyline>
|
||||
<line x1="16" y1="13" x2="8" y2="13"></line>
|
||||
<line x1="16" y1="17" x2="8" y2="17"></line>
|
||||
<polyline points="10 9 9 9 8 9"></polyline>
|
||||
</svg>
|
||||
</div>
|
||||
<h3 class="font-medium text-base mb-1 theme-transition" style="color: var(--text-primary);">名单预设</h3>
|
||||
<p class="text-xs theme-transition" style="color: var(--text-muted);">管理学生名单预设</p>
|
||||
</a>
|
||||
|
||||
<a href="/user_manage" class="quick-action stagger-item group" id="userManageLink" style="display: none;">
|
||||
<div class="w-12 h-12 rounded-xl flex items-center justify-center mb-4 theme-transition"
|
||||
style="background: var(--success-bg);">
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
|
||||
class="theme-transition group-hover:scale-110 transition-transform" style="color: var(--success-text);">
|
||||
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
|
||||
<circle cx="9" cy="7" r="4"></circle>
|
||||
<path d="M23 21v-2a4 4 0 0 0-3-3.87"></path>
|
||||
<path d="M16 3.13a4 4 0 0 1 0 7.75"></path>
|
||||
</svg>
|
||||
</div>
|
||||
<h3 class="font-medium text-base mb-1 theme-transition" style="color: var(--text-primary);">用户管理</h3>
|
||||
<p class="text-xs theme-transition" style="color: var(--text-muted);">管理用户权限</p>
|
||||
</a>
|
||||
|
||||
<a href="/db_manage" class="quick-action stagger-item group" id="dbManageLink" style="display: none;">
|
||||
<div class="w-12 h-12 rounded-xl flex items-center justify-center mb-4 theme-transition"
|
||||
style="background: var(--warning-bg);">
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
|
||||
class="theme-transition group-hover:scale-110 transition-transform" style="color: var(--warning-text);">
|
||||
<ellipse cx="12" cy="5" rx="9" ry="3"></ellipse>
|
||||
<path d="M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"></path>
|
||||
<path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"></path>
|
||||
</svg>
|
||||
</div>
|
||||
<h3 class="font-medium text-base mb-1 theme-transition" style="color: var(--text-primary);">数据库管理</h3>
|
||||
<p class="text-xs theme-transition" style="color: var(--text-muted);">查看状态/执行SQL/优化</p>
|
||||
</a>
|
||||
|
||||
<a href="/monitor" class="quick-action stagger-item group" id="monitorLink" style="display: none;">
|
||||
<div class="w-12 h-12 rounded-xl flex items-center justify-center mb-4 theme-transition"
|
||||
style="background: var(--info-bg);">
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
|
||||
class="theme-transition group-hover:scale-110 transition-transform" style="color: var(--info-text);">
|
||||
<path d="M3 3v18h18"/>
|
||||
<path d="m19 9-5 5-4-4-3 3"/>
|
||||
</svg>
|
||||
</div>
|
||||
<h3 class="font-medium text-base mb-1 theme-transition" style="color: var(--text-primary);">系统监控</h3>
|
||||
<p class="text-xs theme-transition" style="color: var(--text-muted);">性能指标/趋势图表</p>
|
||||
</a>
|
||||
|
||||
|
||||
<a href="http://47.112.187.172:4567/share/1n5ih0p3s0/p/-9DQeaLVvLs" class="quick-action stagger-item group">
|
||||
<div class="w-12 h-12 rounded-xl flex items-center justify-center mb-4 theme-transition"
|
||||
style="background: var(--warning-bg);">
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
|
||||
class="theme-transition group-hover:scale-110 transition-transform" style="color: var(--warning-text);">
|
||||
<circle cx="12" cy="12" r="10"></circle>
|
||||
<line x1="12" y1="16" x2="12" y2="12"></line>
|
||||
<line x1="12" y1="8" x2="12.01" y2="8"></line>
|
||||
</svg>
|
||||
</div>
|
||||
<h3 class="font-medium text-base mb-1 theme-transition" style="color: var(--text-primary);">帮助文档</h3>
|
||||
<p class="text-xs theme-transition" style="color: var(--text-muted);">查看使用指南</p>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Loading State -->
|
||||
<div id="loadingState" class="flex justify-center items-center h-32">
|
||||
<div class="loading-spinner"></div>
|
||||
</div>
|
||||
|
||||
<!-- Forms List -->
|
||||
<div id="formsContainer" class="hidden">
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<h3 class="font-serif text-2xl font-medium theme-transition" style="color: var(--text-primary);">表单列表</h3>
|
||||
<span class="text-sm theme-transition" style="color: var(--text-muted);" id="formCount">0 个表单</span>
|
||||
</div>
|
||||
|
||||
<div id="formsList" class="grid grid-cols-1 lg:grid-cols-2 gap-4">
|
||||
<!-- Forms will be inserted here -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Empty State -->
|
||||
<div id="emptyState" class="hidden text-center py-16">
|
||||
<div class="w-16 h-16 mx-auto mb-6 rounded-full flex items-center justify-center theme-transition"
|
||||
style="background: var(--bg-primary);">
|
||||
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"
|
||||
style="color: var(--text-muted);">
|
||||
<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
|
||||
<polyline points="14 2 14 8 20 8"></polyline>
|
||||
<line x1="16" y1="13" x2="8" y2="13"></line>
|
||||
<line x1="16" y1="17" x2="8" y2="17"></line>
|
||||
<polyline points="10 9 9 9 8 9"></polyline>
|
||||
</svg>
|
||||
</div>
|
||||
<h3 class="font-serif text-2xl font-medium mb-2 theme-transition" style="color: var(--text-primary);">暂无表单</h3>
|
||||
<p class="text-sm mb-6 theme-transition" style="color: var(--text-muted);">点击上方"新建表单"创建第一个表单</p>
|
||||
<a href="/create"
|
||||
class="btn btn-primary inline-flex items-center gap-2 px-6 py-3 rounded-xl text-sm font-medium">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<line x1="12" y1="5" x2="12" y2="19"></line>
|
||||
<line x1="5" y1="12" x2="19" y2="12"></line>
|
||||
</svg>
|
||||
新建表单
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- Footer -->
|
||||
<footer class="fixed bottom-6 w-full text-center pointer-events-none">
|
||||
<p class="text-[10px] tracking-[0.3em] uppercase font-medium theme-transition" style="color: var(--text-muted);">
|
||||
Secure Admin Panel</p>
|
||||
</footer>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
// Page init
|
||||
let currentUser = null;
|
||||
|
||||
// Check auth and load data
|
||||
async function init() {
|
||||
try {
|
||||
const response = await fetch('/api/current_user');
|
||||
const data = await response.json();
|
||||
|
||||
if (!data.logged_in) {
|
||||
window.location.href = '/login?redirect=/admin';
|
||||
return;
|
||||
}
|
||||
|
||||
currentUser = data;
|
||||
|
||||
// Show user management and database management links for admin
|
||||
if (data.role === 'admin') {
|
||||
document.getElementById('userManageLink').style.display = 'block';
|
||||
document.getElementById('dbManageLink').style.display = 'block';
|
||||
document.getElementById('monitorLink').style.display = 'block';
|
||||
}
|
||||
|
||||
loadForms();
|
||||
} catch (error) {
|
||||
showToast('认证失败', 'error');
|
||||
setTimeout(() => {
|
||||
window.location.href = '/login?redirect=/admin';
|
||||
}, 1500);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadForms() {
|
||||
try {
|
||||
const response = await fetch('/api/admin/forms');
|
||||
const forms = await response.json();
|
||||
|
||||
document.getElementById('loadingState').style.display = 'none';
|
||||
|
||||
if (forms.length === 0) {
|
||||
document.getElementById('emptyState').classList.remove('hidden');
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById('formsContainer').classList.remove('hidden');
|
||||
document.getElementById('formCount').textContent = `${forms.length} 个表单`;
|
||||
|
||||
renderForms(forms);
|
||||
|
||||
} catch (error) {
|
||||
showToast('加载表单失败', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
function renderForms(forms) {
|
||||
const container = document.getElementById('formsList');
|
||||
|
||||
container.innerHTML = forms.map((form, index) => {
|
||||
const expiryInfo = form.expiryInfo || {};
|
||||
const remainingDays = expiryInfo.remaining_days || 0;
|
||||
const remainingHours = expiryInfo.remaining_hours || 0;
|
||||
const isExpired = expiryInfo.is_expired || false;
|
||||
|
||||
let expiryText = '';
|
||||
if (expiryInfo.never_expires) {
|
||||
expiryText = '<span class="text-xs px-2 py-1 rounded-full theme-transition" style="background: var(--success-bg); color: var(--success-text);">永不过期</span>';
|
||||
} else if (isExpired) {
|
||||
expiryText = '<span class="text-xs px-2 py-1 rounded-full" style="background: var(--error-bg); color: var(--error-text);">已过期</span>';
|
||||
} else if (remainingDays > 0) {
|
||||
expiryText = `<span class="text-xs px-2 py-1 rounded-full theme-transition" style="background: var(--warning-bg); color: var(--warning-text);">${remainingDays}天${remainingHours}小时后过期</span>`;
|
||||
} else {
|
||||
expiryText = `<span class="text-xs px-2 py-1 rounded-full" style="background: var(--error-bg); color: var(--error-text);">${remainingHours}小时后过期</span>`;
|
||||
}
|
||||
|
||||
return `
|
||||
<div class="form-card" style="animation-delay: ${index * 0.05}s">
|
||||
<div class="flex justify-between items-start mb-4">
|
||||
<div>
|
||||
<h4 class="font-medium text-lg mb-1 theme-transition" style="color: var(--text-primary);">${form.title}</h4>
|
||||
<p class="text-xs theme-transition" style="color: var(--text-muted);">
|
||||
${form.presetName ? `使用预设: ${form.presetName}` : '使用默认名单'}
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex gap-2 items-center">
|
||||
<button type="button"
|
||||
onclick="toggleCollect('${form.id}')"
|
||||
data-toggle-collect="${form.id}"
|
||||
data-collecting="${form.collecting !== false ? '1' : '0'}"
|
||||
title="点击切换收集状态"
|
||||
class="text-xs px-2.5 py-1 rounded-full inline-flex items-center gap-1.5 font-medium theme-transition"
|
||||
style="border:1px solid ${form.collecting !== false ? 'var(--success-text)' : 'var(--error-text)'}; color:${form.collecting !== false ? 'var(--success-text)' : 'var(--error-text)'}; background:${form.collecting !== false ? 'var(--success-bg)' : 'var(--error-bg)'}; cursor:pointer;">
|
||||
<span style="display:inline-block;width:8px;height:8px;border-radius:50%;background:${form.collecting !== false ? 'var(--success-text)' : 'var(--error-text)'};"></span>
|
||||
${form.collecting !== false ? '收集中' : '已停止'}
|
||||
</button>
|
||||
${expiryText}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-3 gap-4 mb-4 py-4 border-y theme-transition" style="border-color: var(--border-color);">
|
||||
<div class="text-center">
|
||||
<div class="text-2xl font-semibold theme-transition" style="color: var(--text-primary);">${form.submittedCount}</div>
|
||||
<div class="text-xs theme-transition" style="color: var(--text-muted);">已提交</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="text-2xl font-semibold theme-transition" style="color: var(--text-primary);">${form.totalStudents}</div>
|
||||
<div class="text-xs theme-transition" style="color: var(--text-muted);">总人数</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="text-2xl font-semibold theme-transition" style="color: var(--text-primary);">${form.fileCount}</div>
|
||||
<div class="text-xs theme-transition" style="color: var(--text-muted);">文件数</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-2">
|
||||
<a href="/status?formId=${form.id}" class="btn btn-manage flex-1 py-2.5 rounded-xl text-xs font-medium text-center">
|
||||
查看状态
|
||||
</a>
|
||||
<a href="/edit/${form.id}" class="btn btn-secondary px-4 py-2.5 rounded-xl text-xs font-medium">
|
||||
编辑
|
||||
</a>
|
||||
<button onclick="deleteForm('${form.id}')" class="btn btn-danger px-4 py-2.5 rounded-xl text-xs font-medium">
|
||||
删除
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
|
||||
// Animate cards
|
||||
gsap.to(".form-card", {
|
||||
opacity: 1,
|
||||
y: 0,
|
||||
duration: 0.5,
|
||||
stagger: 0.05,
|
||||
ease: "power2.out"
|
||||
});
|
||||
}
|
||||
|
||||
async function deleteForm(formId) {
|
||||
if (!confirm('确定要删除此表单吗?此操作不可恢复。')) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/admin/delete_form/${formId}`, {
|
||||
method: 'POST'
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
showToast('表单已删除', 'success');
|
||||
loadForms();
|
||||
} else {
|
||||
showToast(data.message || '删除失败', 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
showToast('删除失败', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleCollect(formId) {
|
||||
const btn = document.querySelector(`[data-toggle-collect="${formId}"]`);
|
||||
const current = btn ? btn.dataset.collecting === '1' : true;
|
||||
const next = !current;
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/admin/toggle_collect/${formId}`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ collecting: next })
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
showToast(data.message || (next ? '已恢复收集' : '已停止收集'), 'success');
|
||||
loadForms();
|
||||
} else {
|
||||
showToast(data.message || '切换失败', 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
showToast('切换失败', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Initial Animation
|
||||
window.addEventListener('load', () => {
|
||||
gsap.to("#headerSection", {
|
||||
opacity: 1,
|
||||
y: 0,
|
||||
duration: 0.8,
|
||||
ease: "power2.out",
|
||||
delay: 0.1
|
||||
});
|
||||
|
||||
gsap.to(".stagger-item", {
|
||||
opacity: 1,
|
||||
y: 0,
|
||||
duration: 0.6,
|
||||
stagger: 0.1,
|
||||
ease: "power2.out",
|
||||
delay: 0.3
|
||||
});
|
||||
|
||||
init();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+2467
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,412 @@
|
||||
<!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="https://cdn.tailwindcss.com"></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="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
||||
<script src="/static/js/particles.js"></script>
|
||||
<link rel="stylesheet" href="/static/css/toast.css">
|
||||
<script src="/static/js/toast.js"></script>
|
||||
<link rel="stylesheet" href="/static/css/basic.css">
|
||||
<link rel="stylesheet" href="/static/css/common.css">
|
||||
<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>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,194 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN" class="light">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<title>登录 - 表单管理系统</title>
|
||||
|
||||
<!-- Tailwind CSS -->
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<script>
|
||||
tailwind.config = {
|
||||
darkMode: 'class',
|
||||
theme: {
|
||||
extend: {
|
||||
fontFamily: {
|
||||
sans: ['Inter', 'sans-serif'],
|
||||
serif: ['Playfair Display', 'serif'],
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- GSAP -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
||||
|
||||
<!-- Particles -->
|
||||
<script src="/static/js/particles.js"></script>
|
||||
|
||||
<!-- Toast -->
|
||||
<script src="/static/js/toast.js"></script>
|
||||
<link rel="stylesheet" href="/static/css/toast.css">
|
||||
|
||||
<!-- Basic & Common Styles -->
|
||||
<link rel="stylesheet" href="/static/css/basic.css">
|
||||
<link rel="stylesheet" href="/static/css/common.css">
|
||||
<!-- Common JS (theme init, utils) -->
|
||||
<script src="/static/js/common.js"></script>
|
||||
|
||||
<style>
|
||||
/* ── login 页面专属样式 ── */
|
||||
.input-wrapper {
|
||||
position: relative;
|
||||
background-color: var(--input-bg);
|
||||
border: 2px solid var(--input-border);
|
||||
border-radius: 12px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.input-wrapper:focus-within {
|
||||
border-color: var(--text-primary);
|
||||
box-shadow: 0 0 0 3px var(--shadow-color);
|
||||
}
|
||||
|
||||
.input-field {
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--input-text);
|
||||
width: 100%;
|
||||
padding: 14px 16px;
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.input-field::placeholder {
|
||||
color: var(--text-muted);
|
||||
opacity: 0.8;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="antialiased min-h-screen flex items-center justify-center relative">
|
||||
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="relative z-10 w-full max-w-md mx-auto px-6 py-12">
|
||||
<div id="loginCard" class="glass rounded-3xl p-8 md:p-10 shadow-2xl opacity-0 transform translate-y-8">
|
||||
|
||||
<div class="text-center mb-10">
|
||||
<h1 class="font-serif text-3xl font-semibold tracking-tight mb-2" style="color: var(--text-primary);">
|
||||
Form Admin
|
||||
</h1>
|
||||
<p class="text-xs tracking-[0.2em] uppercase font-medium" style="color: var(--text-muted);">
|
||||
Secure Login
|
||||
</p>
|
||||
<div class="w-16 h-[2px] mx-auto mt-4" style="background-color: var(--border-color);"></div>
|
||||
</div>
|
||||
|
||||
<form id="loginForm" class="space-y-6">
|
||||
<div class="space-y-2">
|
||||
<label class="block text-xs font-semibold tracking-wide uppercase"
|
||||
style="color: var(--text-secondary);">
|
||||
用户名
|
||||
</label>
|
||||
<div class="input-wrapper">
|
||||
<input type="text" id="username" placeholder="请输入用户名" required autofocus class="input-field"
|
||||
autocomplete="username">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<label class="block text-xs font-semibold tracking-wide uppercase"
|
||||
style="color: var(--text-secondary);">
|
||||
密码
|
||||
</label>
|
||||
<div class="input-wrapper">
|
||||
<input type="password" id="password" placeholder="请输入密码" required class="input-field"
|
||||
autocomplete="current-password">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between text-xs pt-2">
|
||||
<label class="flex items-center cursor-pointer">
|
||||
<input type="checkbox" id="remember" class="mr-2 accent-gray-900 dark:accent-white">
|
||||
<span style="color: var(--text-secondary);">记住我</span>
|
||||
</label>
|
||||
<button type="button" onclick="showToast('请联系管理员重置密码', 'error')"
|
||||
class="font-medium hover:opacity-70 transition-opacity text-xs"
|
||||
style="color: var(--text-muted);">
|
||||
忘记密码?
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<button type="submit" id="loginBtn"
|
||||
class="btn-primary w-full py-4 rounded-xl text-sm font-semibold tracking-wide uppercase flex items-center justify-center mt-8">
|
||||
<span id="btnText">登录</span>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div class="mt-8 pt-6 border-t text-center" style="border-color: var(--border-color);">
|
||||
<div class="flex items-center justify-center gap-2 text-[10px] tracking-[0.2em] uppercase font-medium"
|
||||
style="color: var(--text-muted);">
|
||||
<span>Secure Admin Panel</span>
|
||||
<span>•</span>
|
||||
<span id="clock">00:00</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
// Clock
|
||||
setInterval(() => {
|
||||
document.getElementById('clock').textContent =
|
||||
new Date().toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit', hour12: false });
|
||||
}, 1000);
|
||||
|
||||
// GSAP
|
||||
window.addEventListener('load', () => {
|
||||
gsap.to("#loginCard", { opacity: 1, y: 0, duration: 0.8, ease: "power2.out", delay: 0.2 });
|
||||
});
|
||||
|
||||
|
||||
// Form
|
||||
document.getElementById('loginForm').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const btn = document.getElementById('loginBtn');
|
||||
const btnText = document.getElementById('btnText');
|
||||
|
||||
btn.disabled = true;
|
||||
btnText.innerHTML = '登录中<span class="loading-spinner"></span>';
|
||||
|
||||
try {
|
||||
const res = await fetch('/api/login', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
username: document.getElementById('username').value.trim(),
|
||||
password: document.getElementById('password').value,
|
||||
remember: document.getElementById('remember').checked
|
||||
})
|
||||
});
|
||||
const data = await res.json();
|
||||
|
||||
if (data.success) {
|
||||
showToast('登录成功', 'success');
|
||||
setTimeout(() => location.href = data.redirect || '/admin', 500);
|
||||
} else {
|
||||
showToast(data.message, 'error');
|
||||
btn.disabled = false;
|
||||
btnText.textContent = '重新登录';
|
||||
}
|
||||
} catch {
|
||||
showToast('网络错误', 'error');
|
||||
btn.disabled = false;
|
||||
btnText.textContent = '重新登录';
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,151 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN" class="dark">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="color-scheme" content="dark">
|
||||
<title>文字动效实验室 · Form System</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link href="https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Inter:wght@400;500;600;700&family=Noto+Sans+SC:wght@400;500;600;700&display=swap" rel="stylesheet">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.5/gsap.min.js"></script>
|
||||
<script src="/static/vendor/charwrapper.min.js"></script>
|
||||
<script src="https://unpkg.com/split-type@0.3.4/umd/index.min.js"></script>
|
||||
<style>
|
||||
:root{color-scheme:dark;--bg:#081321;--panel:#101f33;--panel2:#142740;--line:#263d5c;--ink:#eef4ff;--muted:#9aacc5;--soft:#7085a3;--blue:#91b2ff;--cyan:#65d8d0;--amber:#ffc66e;--mono:'DM Mono',monospace;--sans:Inter,'Noto Sans SC',sans-serif}
|
||||
*{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;background:radial-gradient(ellipse at 78% -15%,#1c3760 0,transparent 42%),radial-gradient(ellipse at 2% 70%,#122741 0,transparent 34%),var(--bg);color:var(--ink);font:15px/1.65 var(--sans);min-height:100vh}body:before{content:"";position:fixed;inset:0;pointer-events:none;opacity:.17;background-image:radial-gradient(#8298b8 1px,transparent 1px);background-size:46px 46px;mask-image:linear-gradient(to bottom,#000,transparent 78%)}
|
||||
.topbar{height:66px;border-bottom:1px solid #253956;background:#0d1b2dcc;backdrop-filter:blur(18px);display:flex;align-items:center;justify-content:space-between;padding:0 max(24px,calc((100vw - 1120px)/2));position:sticky;top:0;z-index:10}.brand{font:500 12px var(--mono);letter-spacing:.28em;color:#d9e5fa}.topmeta{font:11px var(--mono);color:var(--soft);letter-spacing:.1em}.wrap{width:min(100% - 40px,1040px);margin:auto;position:relative}.hero{padding:76px 0 34px}.eyebrow{display:flex;align-items:center;gap:10px;color:var(--blue);font-size:11px;font-weight:700;letter-spacing:.18em;text-transform:uppercase}.dot{width:8px;height:8px;border-radius:50%;background:var(--blue);box-shadow:0 0 15px #91b2ff}.hero h1{font-size:clamp(36px,6vw,66px);letter-spacing:-.055em;line-height:1.08;margin:18px 0 16px;max-width:760px}.hero p{color:var(--muted);font-size:16px;max-width:680px;margin:0}.hero-note{margin-top:25px;padding:15px 18px;border:1px solid #2a4262;background:#102039a8;border-radius:14px;color:#aebed3;font-size:13px;display:flex;gap:12px;align-items:flex-start}.hero-note b{color:var(--blue);font:11px var(--mono);letter-spacing:.1em;white-space:nowrap;padding-top:3px}
|
||||
.stack{display:grid;gap:18px;padding:20px 0 80px}.card{position:relative;overflow:hidden;background:linear-gradient(145deg,#13253bfa,#0e1c2ff5);border:1px solid #29415f;border-radius:22px;padding:clamp(22px,4vw,38px);box-shadow:0 22px 70px #0209145c}.card:after{content:"";position:absolute;right:-80px;top:-100px;width:250px;height:250px;border-radius:50%;background:#8bb0ff0b;filter:blur(22px);pointer-events:none}.card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:20px;position:relative;z-index:1}.tag{display:inline-flex;align-items:center;gap:8px;font:11px var(--mono);letter-spacing:.1em;text-transform:uppercase;color:var(--blue)}.tag i{font-style:normal;color:#778daa}.card h2{font-size:23px;letter-spacing:-.03em;margin:8px 0 6px}.desc{color:var(--muted);font-size:13px;margin:0;max-width:650px}.repo{font:11px var(--mono);color:#a9bad2;text-decoration:none;border:1px solid #304968;border-radius:999px;padding:8px 12px;white-space:nowrap;transition:.2s}.repo:hover{border-color:var(--blue);color:var(--blue);transform:translateY(-1px)}
|
||||
.demo{margin-top:24px;padding:22px;border:1px solid #293f5d;border-radius:16px;background:#091728a8;position:relative;z-index:1}.demo-label{font:10px var(--mono);letter-spacing:.14em;color:#7489a5;text-transform:uppercase;margin-bottom:13px}.demo-line{display:flex;align-items:center;gap:16px;flex-wrap:wrap}.sample{min-height:54px;display:flex;align-items:center;font-size:clamp(24px,4vw,36px);font-weight:600;letter-spacing:-.035em;line-height:1.35}.sample.small{font-size:20px}.sample .char{display:inline-block;white-space:pre}.sample .char-add{color:var(--cyan)}.sample .char-remove{color:#f38e9e}.sample .char-add,.sample .char-remove{overflow:hidden}.pill{font:11px var(--mono);color:#a9bad2;background:#142741;border:1px solid #2a4261;border-radius:999px;padding:6px 10px}.controls{display:flex;gap:9px;flex-wrap:wrap;margin-top:18px}.btn{appearance:none;border:1px solid #385376;background:#142943;color:#dce8fa;padding:10px 15px;border-radius:999px;font:600 12px var(--sans);cursor:pointer;transition:transform .2s,border-color .2s,background .2s}.btn:hover{transform:translateY(-2px);border-color:#91b2ff;background:#1b3555}.btn.primary{background:var(--blue);border-color:var(--blue);color:#0a1a31}.btn.primary:hover{background:#b0c7ff}.btn:focus-visible{outline:2px solid #fff;outline-offset:3px}.explain{display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-top:20px}.fact{padding:12px 14px;border-left:2px solid #385575;background:#102139;border-radius:0 10px 10px 0;color:#9eafc6;font-size:12px}.fact strong{display:block;color:#dfe9f8;font-size:12px;margin-bottom:3px}.readout{font:12px var(--mono);color:#d2e2fa;min-width:78px}.split-phrase{font-size:clamp(27px,4vw,38px);font-weight:600;letter-spacing:.01em}.split-phrase .char{display:inline-block;will-change:transform,opacity}.counter{display:flex;align-items:center;gap:5px;min-height:64px;font:600 clamp(28px,5vw,54px)/1 var(--mono);font-variant-numeric:tabular-nums;color:var(--blue)}.roller-cell{display:inline-flex;align-items:center;justify-content:center;overflow:hidden;min-width:.68em;height:1.18em;padding:0 .08em;border:1px solid #385274;border-radius:9px;background:linear-gradient(180deg,#1a304c,#102239);box-shadow:inset 0 1px #ffffff0b,0 5px 15px #02091430;will-change:transform}.roller-cell.is-cjk{min-width:1.08em;font-family:var(--sans);font-size:.8em;font-weight:700}.roller-cell.is-separator{min-width:.28em;padding:0;border-color:transparent;background:transparent;box-shadow:none;color:#8095b2}.roller-cell.cell-enter{animation:cell-enter .5s cubic-bezier(.2,.85,.25,1.2) both}@keyframes cell-enter{from{opacity:0;transform:translateY(55%) scale(.82);filter:blur(5px)}to{opacity:1;transform:translateY(0) scale(1);filter:blur(0)}}.counter-wrap{display:flex;align-items:center;gap:12px;flex-wrap:wrap}.unit{color:var(--muted);font-size:15px}.lib-status{font:10px var(--mono);color:var(--soft);margin-top:12px}.lib-status[data-state="error"]{color:#ff9eaa}.lib-status[data-state="ok"]{color:#8fddbd}.footer{color:#617792;text-align:center;font:10px var(--mono);letter-spacing:.12em;padding:0 0 36px}
|
||||
@media(max-width:680px){.topbar{height:58px;padding:0 20px}.topmeta{display:none}.wrap{width:min(100% - 28px,1040px)}.hero{padding:55px 0 24px}.card-head{display:block}.repo{display:inline-flex;margin-top:14px}.demo{padding:18px 15px}.explain{grid-template-columns:1fr}.hero-note{display:block}.hero-note b{display:block;margin-bottom:4px}}
|
||||
@media(prefers-reduced-motion:reduce){*,*:before,*:after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}}
|
||||
</style>
|
||||
<style>
|
||||
/* Metamorphosis owns the segment layout; style each generated glyph without splitting control. */
|
||||
#rollCounter{display:block;min-height:64px;font:600 clamp(28px,5vw,54px)/1.18 var(--mono);font-variant-numeric:tabular-nums;letter-spacing:normal;white-space:nowrap;color:var(--blue)}
|
||||
#rollCounter .metamorphosis-item{display:inline-block;vertical-align:baseline;min-width:.66em;padding:0 .025em;margin-inline:.015em;text-align:center;border:1px solid #385274;border-radius:7px;background:linear-gradient(180deg,#1a304c,#102239);box-shadow:inset 0 1px #ffffff0b;will-change:transform,opacity}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header class="topbar"><div class="brand">FORM SYSTEM <span style="color:#7085a3">/ MOTION LAB</span></div><div class="topmeta">TEXT TRANSITION STUDIES · 001—003</div></header>
|
||||
<main class="wrap">
|
||||
<section class="hero">
|
||||
<div class="eyebrow"><span class="dot"></span> TYPE IN MOTION / INTERACTIVE STUDY</div>
|
||||
<h1>让变化的文字,<br>自己动起来。</h1>
|
||||
<p>三个开源库,三种文字变化方式。点按钮试试看:智能识别增删、老虎机数字滚动,以及拆字后的自定义入场动效。</p>
|
||||
<div class="hero-note"><b>HOW TO READ</b><span>这页是可操作的对比样例。每个模块都用真实库驱动;如果浏览器无法访问 CDN,会在模块下方显示加载状态。</span></div>
|
||||
</section>
|
||||
<section class="stack" aria-label="文字动画库示例">
|
||||
<article class="card">
|
||||
<div class="card-head"><div><div class="tag">01 <i>/ SMART DIFF</i></div><h2>字符增删 · 平滑让位</h2><p class="desc">适合状态文案或短句变化。尝试让“文字”变为“文1字”,保留匹配字符,只为新增字符做入场,邻字随排版自然让位。</p></div><a class="repo" href="https://github.com/rowild/charwrapper" target="_blank" rel="noreferrer">GITHUB ↗</a></div>
|
||||
<div class="demo"><div class="demo-label">LIVE TRANSITION / CHARWRAPPER + GSAP</div><div class="demo-line"><div class="sample" id="smartText" aria-live="polite">文字</div><span class="pill">新增字符从下方进入</span></div><div class="controls"><button class="btn primary" id="smartInsert">插入「1」</button><button class="btn" id="smartRemove">恢复「文字」</button><button class="btn" id="smartPhrase">试试另一句</button></div><div class="lib-status" id="charStatus" role="status">正在加载 CharWrapper…</div></div>
|
||||
<div class="explain"><div class="fact"><strong>智能匹配</strong>优先复用前后两版中相同的字符。</div><div class="fact"><strong>变化处才动</strong>可设置新增、删除时长与错开间隔。</div><div class="fact"><strong>调用方式</strong>文字更新时调用 transitionTo;不是全页自动监听。</div></div>
|
||||
</article>
|
||||
|
||||
<article class="card">
|
||||
<div class="card-head"><div><div class="tag">02 <i>/ CASCADE ROLL</i></div><h2>逐字滚动 · 中文也能用</h2><p class="desc">中文汉字和数字都按字素分段。库会为每个字生成独立的 DOM 节点,同时由一个控制器协调整句排版和级联动画,让相邻字符移动得更连贯。</p></div><a class="repo" href="https://github.com/olicarignan/metamorphosis" target="_blank" rel="noreferrer">GITHUB ↗</a></div>
|
||||
<div class="demo"><div class="demo-label">LIVE TRANSITION / METAMORPHOSIS · ONE SEGMENT PER GLYPH</div><div class="demo-line counter-wrap"><div class="counter" id="rollCounter" aria-live="polite"></div><span class="unit" id="rollUnit">次提交</span><span class="pill" id="rollMode">数字模式 · 按位滚动</span></div><div class="controls"><button class="btn primary" id="rollNext">增加数值</button><button class="btn" id="rollRandom">随机跳转</button><button class="btn" id="rollReset">重置</button><button class="btn" id="rollChinese" aria-pressed="false">循环处理中…</button></div><div class="lib-status" id="morphStatus" role="status">正在加载 Metamorphosis…</div></div>
|
||||
<div class="explain"><div class="fact"><strong>逐字素切分</strong>“提交成功”会成为四个独立的字素节点。</div><div class="fact"><strong>独立样式,统一编排</strong>每字可用 CSS 单独设样式,控制器负责同步更新与错峰。</div><div class="fact"><strong>顺序与布局</strong>一条文本用一个控制器,库自动测量新旧位置并平滑让位。</div></div>
|
||||
</article>
|
||||
|
||||
<article class="card">
|
||||
<div class="card-head"><div><div class="tag">03 <i>/ SPLIT & ANIMATE</i></div><h2>拆开文字 · 自由编排</h2><p class="desc">SplitType 把文字拆成可单独控制的字符节点,再交给 GSAP 做淡入、上移和错峰。适合标题入场、提示文案和一次性的强调动画。</p></div><a class="repo" href="https://github.com/lukePeavey/SplitType" target="_blank" rel="noreferrer">GITHUB ↗</a></div>
|
||||
<div class="demo"><div class="demo-label">LIVE REVEAL / SPLITTYPE + GSAP</div><div class="demo-line"><div class="sample split-phrase" id="splitText">每个字符都能独立起舞</div><span class="pill">逐字错峰揭示</span></div><div class="controls"><button class="btn primary" id="splitReplay">重新播放</button><button class="btn" id="splitSwap">换一句</button></div><div class="lib-status" id="splitStatus" role="status">正在加载 SplitType…</div></div>
|
||||
<div class="explain"><div class="fact"><strong>粒度清晰</strong>拆成字符、词或行,逐个取得元素。</div><div class="fact"><strong>动画自由</strong>配合 GSAP、CSS 或 Web Animations API。</div><div class="fact"><strong>需要手动更新</strong>文本变化后重新拆分,再启动目标动画。</div></div>
|
||||
</article>
|
||||
</section>
|
||||
<footer class="footer">FORM SYSTEM · MOTION EXPERIMENTS · RESPECT REDUCED MOTION</footer>
|
||||
</main>
|
||||
|
||||
<script type="module">
|
||||
const reduced = matchMedia('(prefers-reduced-motion: reduce)').matches;
|
||||
const setStatus = (id, message, state='ok') => { const el=document.getElementById(id); el.textContent=message; el.dataset.state=state; };
|
||||
const safeGsap = window.gsap;
|
||||
|
||||
// 01 — CharWrapper keeps matched glyphs and animates only insertions/removals.
|
||||
const smartEl=document.getElementById('smartText');
|
||||
let charWrapper=null, smartValue='文字';
|
||||
try {
|
||||
if (!window.CharWrapper) throw new Error('CharWrapper 加载失败:上游仓库没有发布 npm/CDN 构建文件');
|
||||
if (!safeGsap) throw new Error('GSAP 未加载,请检查 CDN 网络连接');
|
||||
charWrapper=new window.CharWrapper(smartEl,{wrap:{chars:true}});
|
||||
charWrapper.wrap();
|
||||
setStatus('charStatus','已就绪 · 点击按钮触发 transitionTo()');
|
||||
} catch(e) { setStatus('charStatus',e.message,'error'); }
|
||||
function smartTo(next){
|
||||
if(!charWrapper)return;
|
||||
smartValue=next;
|
||||
charWrapper.transitionTo(next,{strategy:'smart',addDuration:.52,removeDuration:.32,stagger:.035,ease:'power3.out'});
|
||||
}
|
||||
document.getElementById('smartInsert').onclick=()=>smartTo('文1字');
|
||||
document.getElementById('smartRemove').onclick=()=>smartTo('文字');
|
||||
document.getElementById('smartPhrase').onclick=()=>smartTo(smartValue==='报名成功!'?'表单已提交':'报名成功!');
|
||||
|
||||
// 02 — One controller coordinates the library's per-grapheme DOM segments.
|
||||
const rollRoot=document.getElementById('rollCounter');
|
||||
let morphController=null, count=8042, dotTimer=null, dotStateIndex=0;
|
||||
function updateRollingText(value){
|
||||
if(!morphController)return;
|
||||
rollRoot.setAttribute('aria-label',value);
|
||||
morphController.update(value);
|
||||
}
|
||||
function showNumber(value){
|
||||
stopProcessingLoop();
|
||||
count=value;
|
||||
document.getElementById('rollUnit').textContent='次提交';
|
||||
document.getElementById('rollMode').textContent='数字模式 · 按位滚动';
|
||||
updateRollingText(count.toLocaleString('en-US'));
|
||||
}
|
||||
function showChinese(){
|
||||
if(dotTimer){stopProcessingLoop();return;}
|
||||
const states=['处理中.','处理中..','处理中...'];
|
||||
dotStateIndex=0;
|
||||
document.getElementById('rollUnit').textContent='中文文案';
|
||||
document.getElementById('rollMode').textContent='循环切换 · 900 ms';
|
||||
document.getElementById('rollChinese').textContent='停止循环';
|
||||
document.getElementById('rollChinese').setAttribute('aria-pressed','true');
|
||||
updateRollingText(states[dotStateIndex]);
|
||||
dotTimer=setInterval(()=>{
|
||||
dotStateIndex=(dotStateIndex+1)%states.length;
|
||||
updateRollingText(states[dotStateIndex]);
|
||||
},900);
|
||||
}
|
||||
function stopProcessingLoop(){
|
||||
if(dotTimer){clearInterval(dotTimer);dotTimer=null;}
|
||||
const button=document.getElementById('rollChinese');
|
||||
if(button){button.textContent='循环处理中…';button.setAttribute('aria-pressed','false');}
|
||||
}
|
||||
try {
|
||||
const {MorphController}=await import('https://esm.sh/@ocarignan/metamorphosis@latest');
|
||||
morphController=new MorphController();
|
||||
morphController.attach(rollRoot,{
|
||||
granularity:'grapheme',locale:'zh-CN',cascade:true,enterSlide:24,stagger:30,
|
||||
duration:460,ease:'cubic-bezier(.2,.8,.2,1)',respectReducedMotion:true
|
||||
});
|
||||
showNumber(count);
|
||||
setStatus('morphStatus','已就绪 · 单控制器协调整行逐字滚动');
|
||||
} catch(e) { setStatus('morphStatus','加载失败:'+e.message,'error'); }
|
||||
function updateCount(value){if(!morphController)return;showNumber(value);}
|
||||
document.getElementById('rollNext').onclick=()=>updateCount(count+Math.ceil(Math.random()*917));
|
||||
document.getElementById('rollRandom').onclick=()=>updateCount(Math.floor(120+Math.random()*120000));
|
||||
document.getElementById('rollReset').onclick=()=>updateCount(8042);
|
||||
document.getElementById('rollChinese').onclick=()=>{if(morphController)showChinese()};
|
||||
|
||||
// 03 — SplitType only splits; GSAP provides the actual reveal choreography.
|
||||
const splitEl=document.getElementById('splitText');
|
||||
let splitInstance=null, splitToggle=false;
|
||||
function replaySplit(){
|
||||
if(!window.SplitType||!safeGsap)return;
|
||||
if(splitInstance)splitInstance.revert();
|
||||
splitInstance=new window.SplitType(splitEl,{types:'words, chars',tagName:'span'});
|
||||
safeGsap.killTweensOf(splitInstance.chars);
|
||||
safeGsap.fromTo(splitInstance.chars,{yPercent:110,opacity:0,rotateX:-45},{yPercent:0,opacity:1,rotateX:0,duration:reduced?0:.62,stagger:reduced?0:.025,ease:'power3.out',clearProps:'transform,opacity'});
|
||||
}
|
||||
if(window.SplitType&&safeGsap){setStatus('splitStatus','已就绪 · 拆分字符后用 GSAP 编排');requestAnimationFrame(replaySplit)}
|
||||
else setStatus('splitStatus','SplitType 或 GSAP 未能从 CDN 加载','error');
|
||||
document.getElementById('splitReplay').onclick=replaySplit;
|
||||
document.getElementById('splitSwap').onclick=()=>{splitToggle=!splitToggle; if(splitInstance)splitInstance.revert();splitEl.textContent=splitToggle?'变化也可以很有节奏':'每个字符都能独立起舞';replaySplit()};
|
||||
window.addEventListener('pagehide',()=>{stopProcessingLoop();morphController?.destroy()});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,846 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN" class="light">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<title>用户管理 - 表单管理系统</title>
|
||||
|
||||
<!-- Tailwind CSS -->
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<script>
|
||||
tailwind.config = {
|
||||
darkMode: 'class',
|
||||
theme: {
|
||||
extend: {
|
||||
fontFamily: {
|
||||
sans: ['Inter', 'sans-serif'],
|
||||
serif: ['Playfair Display', 'serif'],
|
||||
},
|
||||
colors: {
|
||||
neutral: {
|
||||
50: '#fafafa',
|
||||
100: '#f5f5f5',
|
||||
200: '#e5e5e5',
|
||||
300: '#d4d4d4',
|
||||
400: '#a3a3a3',
|
||||
500: '#737373',
|
||||
600: '#525252',
|
||||
700: '#404040',
|
||||
800: '#262626',
|
||||
900: '#171717',
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- GSAP for animations -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
|
||||
<script src="/static/js/particles.js"></script>
|
||||
<script src="/static/js/toast.js"></script>
|
||||
<link rel="stylesheet" href="/static/css/basic.css">
|
||||
<link rel="stylesheet" href="/static/css/common.css">
|
||||
<script src="/static/js/common.js"></script>
|
||||
|
||||
<style>
|
||||
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Playfair+Display:ital,wght@0,400;0,600;1,400&display=swap');
|
||||
|
||||
@import url('/static/css/toast.css');
|
||||
|
||||
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Inter', sans-serif;
|
||||
background-color: var(--bg-primary);
|
||||
background-image:
|
||||
radial-gradient(at 0% 0%, rgba(128,128,128,0.03) 0px, transparent 50%),
|
||||
radial-gradient(at 100% 100%, rgba(128,128,128,0.03) 0px, transparent 50%);
|
||||
color: var(--text-primary);
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
overflow-x: hidden;
|
||||
transition: background-color 0.5s ease, color 0.5s ease;
|
||||
}
|
||||
|
||||
.dark body {
|
||||
background-image:
|
||||
radial-gradient(at 0% 0%, rgba(255,255,255,0.02) 0px, transparent 50%),
|
||||
radial-gradient(at 100% 100%, rgba(255,255,255,0.02) 0px, transparent 50%);
|
||||
}
|
||||
|
||||
.glass {
|
||||
background: var(--glass-bg);
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
border: 1px solid var(--glass-border);
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.glass:hover {
|
||||
background: var(--glass-hover);
|
||||
}
|
||||
|
||||
.theme-transition {
|
||||
transition: background-color 0.5s ease, color 0.5s ease, border-color 0.5s ease, box-shadow 0.5s ease;
|
||||
}
|
||||
|
||||
/* User Card */
|
||||
.user-card {
|
||||
background: var(--glass-bg);
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
border: 1px solid var(--glass-border);
|
||||
border-radius: 24px;
|
||||
padding: 24px;
|
||||
transition: all 0.4s cubic-bezier(0.2, 0, 0, 1);
|
||||
opacity: 0;
|
||||
transform: translateY(20px);
|
||||
}
|
||||
|
||||
.user-card:hover {
|
||||
transform: translateY(-4px);
|
||||
box-shadow: 0 20px 40px -15px var(--shadow-color);
|
||||
border-color: rgba(128,128,128,0.3);
|
||||
|
||||
background: var(--glass-hover);
|
||||
}
|
||||
|
||||
/* Role Badge */
|
||||
.role-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 4px 12px;
|
||||
border-radius: 9999px;
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.05em;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.role-admin {
|
||||
background: var(--error-bg);
|
||||
color: var(--error-text);
|
||||
border: 1px solid var(--error-border);
|
||||
}
|
||||
|
||||
.role-user {
|
||||
background: rgba(99, 102, 241, 0.1);
|
||||
color: #6366f1;
|
||||
border: 1px solid rgba(99, 102, 241, 0.2);
|
||||
}
|
||||
|
||||
.dark .role-user {
|
||||
background: rgba(99, 102, 241, 0.2);
|
||||
color: #818cf8;
|
||||
border-color: rgba(99, 102, 241, 0.3);
|
||||
}
|
||||
|
||||
/* Buttons */
|
||||
.btn {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
transition: all 0.3s cubic-bezier(0.2, 0, 0, 1);
|
||||
}
|
||||
|
||||
.btn::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: -100%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, transparent, rgba(128,128,128,0.1), transparent);
|
||||
transition: left 0.5s;
|
||||
}
|
||||
|
||||
.btn:hover::before {
|
||||
left: 100%;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: var(--accent-bg);
|
||||
color: var(--accent-text);
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 10px 20px -5px var(--shadow-color);
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background-color: var(--bg-primary);
|
||||
color: var(--text-secondary);
|
||||
border: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.btn-secondary:hover {
|
||||
background-color: var(--bg-secondary);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.btn-manage {
|
||||
background-color: rgba(99, 102, 241, 0.1);
|
||||
color: #6366f1;
|
||||
border: 1px solid rgba(99, 102, 241, 0.2);
|
||||
}
|
||||
|
||||
.btn-manage:hover {
|
||||
background-color: rgba(99, 102, 241, 0.2);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background-color: var(--danger-bg);
|
||||
color: var(--danger-text);
|
||||
border: 1px solid var(--error-border);
|
||||
}
|
||||
|
||||
.btn-danger:hover {
|
||||
opacity: 0.8;
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.btn-danger:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
/* Modal */
|
||||
.modal-overlay {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 5000;
|
||||
display: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(0,0,0,0.4);
|
||||
backdrop-filter: blur(12px);
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.modal-overlay.show {
|
||||
display: flex;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.modal-box {
|
||||
background: var(--bg-secondary);
|
||||
border: 1px solid var(--glass-border);
|
||||
border-radius: 24px;
|
||||
padding: 32px;
|
||||
width: 90%;
|
||||
max-width: 480px;
|
||||
max-height: 90vh;
|
||||
overflow-y: auto;
|
||||
transform: scale(0.95);
|
||||
transition: transform 0.3s cubic-bezier(0.2, 0, 0, 1);
|
||||
}
|
||||
|
||||
.modal-overlay.show .modal-box {
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.modal-box {
|
||||
width: 100%;
|
||||
max-width: none;
|
||||
max-height: 100vh;
|
||||
border-radius: 24px 24px 0 0;
|
||||
margin-top: auto;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.modal-overlay {
|
||||
align-items: flex-end;
|
||||
}
|
||||
}
|
||||
|
||||
/* Form Elements */
|
||||
.input-field {
|
||||
background-color: var(--bg-primary);
|
||||
border: 2px solid var(--border-color);
|
||||
border-radius: 12px;
|
||||
color: var(--text-primary);
|
||||
width: 100%;
|
||||
padding: 14px 16px;
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
outline: none;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.input-field:focus {
|
||||
border-color: var(--text-primary);
|
||||
box-shadow: 0 0 0 4px var(--shadow-color);
|
||||
}
|
||||
|
||||
.input-field::placeholder {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.checkbox-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
padding: 12px;
|
||||
background: var(--bg-primary);
|
||||
border-radius: 12px;
|
||||
border: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.checkbox-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 10px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
font-size: 14px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.checkbox-item:hover {
|
||||
background: var(--bg-secondary);
|
||||
}
|
||||
|
||||
.checkbox-item input[type="checkbox"] {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
accent-color: var(--accent-bg);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
||||
/* Loading */
|
||||
.loading-spinner {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border: 3px solid var(--border-color);
|
||||
border-top-color: var(--text-primary);
|
||||
border-radius: 50%;
|
||||
animation: spin 0.8s linear infinite;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
/* Scrollbar */
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: var(--border-color);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--text-muted);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="antialiased min-h-screen relative">
|
||||
|
||||
<!-- Header -->
|
||||
<header class="fixed top-0 w-full z-40 px-4 sm:px-6 py-4 sm:py-5 glass theme-transition border-b">
|
||||
<div class="max-w-6xl mx-auto flex justify-between items-center">
|
||||
<!-- 左侧:面包屑 -->
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="/admin" class="nav-link flex items-center gap-1.5">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none"
|
||||
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/>
|
||||
<rect x="14" y="14" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/>
|
||||
</svg>
|
||||
<span class="hidden sm:inline text-sm">管理后台</span>
|
||||
</a>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none"
|
||||
stroke="currentColor" stroke-width="2" style="color:var(--text-muted);opacity:0.4">
|
||||
<path d="m9 18 6-6-6-6"/>
|
||||
</svg>
|
||||
<span class="text-sm font-medium" style="color:var(--text-primary)">用户管理</span>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-2 sm:gap-3">
|
||||
<a href="/admin" class="btn btn-secondary px-4 py-2.5 rounded-full text-xs sm:text-sm font-medium tracking-wide flex items-center gap-2">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M19 12H5M12 19l-7-7 7-7"/>
|
||||
</svg>
|
||||
<span class="hidden sm:inline">返回</span>
|
||||
</a>
|
||||
|
||||
<button onclick="showAddUserModal()" class="btn btn-primary px-4 py-2.5 rounded-full text-xs sm:text-sm font-medium tracking-wide flex items-center gap-2">
|
||||
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
|
||||
<line x1="12" y1="5" x2="12" y2="19"></line>
|
||||
<line x1="5" y1="12" x2="19" y2="12"></line>
|
||||
</svg>
|
||||
<span class="hidden sm:inline">添加用户</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<!-- Main Content -->
|
||||
<main class="relative pt-28 sm:pt-36 pb-24 px-4 sm:px-6">
|
||||
<div class="max-w-6xl mx-auto">
|
||||
|
||||
<!-- Header Section -->
|
||||
<div class="mb-8 sm:mb-12 opacity-0" id="headerSection">
|
||||
<h2 class="font-serif text-3xl sm:text-4xl font-medium tracking-tight mb-3 theme-transition" style="color: var(--text-primary);">
|
||||
用户管理
|
||||
</h2>
|
||||
<p class="text-sm leading-relaxed max-w-md tracking-wide font-light theme-transition" style="color: var(--text-secondary);">
|
||||
管理系统用户账号,分配表单管理权限,保障系统安全。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- Loading State -->
|
||||
<div id="loading" class="flex justify-center items-center h-64">
|
||||
<div class="loading-spinner"></div>
|
||||
</div>
|
||||
|
||||
<!-- Users Grid -->
|
||||
<div id="usersContainer" class="grid grid-cols-1 lg:grid-cols-2 gap-4 sm:gap-6" style="display: none;"></div>
|
||||
|
||||
<!-- Empty State -->
|
||||
<div id="emptyState" class="hidden text-center py-24">
|
||||
<div class="w-16 h-16 mx-auto mb-6 rounded-full flex items-center justify-center theme-transition" style="background-color: var(--bg-primary);">
|
||||
<svg width="32" height="32" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" style="color: var(--text-muted);">
|
||||
<path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
|
||||
<circle cx="9" cy="7" r="4"></circle>
|
||||
<path d="M23 21v-2a4 4 0 0 0-3-3.87"></path>
|
||||
<path d="M16 3.13a4 4 0 0 1 0 7.75"></path>
|
||||
</svg>
|
||||
</div>
|
||||
<h3 class="font-serif text-2xl font-medium mb-2 theme-transition" style="color: var(--text-primary);">暂无用户</h3>
|
||||
<p class="text-sm theme-transition" style="color: var(--text-muted);">点击上方按钮添加第一个用户</p>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<!-- Footer -->
|
||||
<footer class="fixed bottom-6 w-full text-center pointer-events-none">
|
||||
<p class="text-[10px] tracking-[0.3em] uppercase font-medium theme-transition" style="color: var(--text-muted);">Secure Admin Panel</p>
|
||||
</footer>
|
||||
|
||||
|
||||
<!-- Add User Modal -->
|
||||
<div class="modal-overlay" id="addUserModal">
|
||||
<div class="modal-box">
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<h3 class="font-serif text-xl font-semibold theme-transition" style="color: var(--text-primary);">添加新用户</h3>
|
||||
<button onclick="closeAddUserModal()" class="p-2 rounded-full hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors" style="color: var(--text-muted);">
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<line x1="18" y1="6" x2="6" y2="18"></line>
|
||||
<line x1="6" y1="6" x2="18" y2="18"></line>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="space-y-5">
|
||||
<div>
|
||||
<label class="block text-xs font-semibold tracking-wide uppercase mb-2 theme-transition" style="color: var(--text-secondary);">
|
||||
用户名
|
||||
</label>
|
||||
<input type="text" id="newUsername" placeholder="请输入用户名" maxlength="20" class="input-field">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-xs font-semibold tracking-wide uppercase mb-2 theme-transition" style="color: var(--text-secondary);">
|
||||
密码
|
||||
</label>
|
||||
<input type="password" id="newPassword" placeholder="请输入密码(至少6位)" minlength="6" class="input-field">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-xs font-semibold tracking-wide uppercase mb-2 theme-transition" style="color: var(--text-secondary);">
|
||||
角色
|
||||
</label>
|
||||
<select id="userRole" class="input-field cursor-pointer">
|
||||
<option value="user">普通用户</option>
|
||||
<option value="admin">管理员</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-3 mt-8">
|
||||
<button onclick="closeAddUserModal()" class="btn btn-secondary flex-1 py-3 rounded-xl text-sm font-medium">
|
||||
取消
|
||||
</button>
|
||||
<button onclick="addUser()" class="btn btn-primary flex-1 py-3 rounded-xl text-sm font-medium">
|
||||
添加
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Permissions Modal -->
|
||||
<div class="modal-overlay" id="permsModal">
|
||||
<div class="modal-box">
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<h3 class="font-serif text-xl font-semibold theme-transition" style="color: var(--text-primary);">
|
||||
表单权限 - <span id="permsUsername" class="text-base font-normal" style="color: var(--text-secondary);"></span>
|
||||
</h3>
|
||||
<button onclick="closePermsModal()" class="p-2 rounded-full hover:bg-gray-100 dark:hover:bg-gray-800 transition-colors" style="color: var(--text-muted);">
|
||||
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<line x1="18" y1="6" x2="6" y2="18"></line>
|
||||
<line x1="6" y1="6" x2="18" y2="18"></line>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-xs font-semibold tracking-wide uppercase mb-3 theme-transition" style="color: var(--text-secondary);">
|
||||
选择可管理的表单
|
||||
</label>
|
||||
<div class="checkbox-group" id="formsCheckboxes">
|
||||
<!-- Checkboxes will be inserted here -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-3 mt-6">
|
||||
<button onclick="closePermsModal()" class="btn btn-secondary flex-1 py-3 rounded-xl text-sm font-medium">
|
||||
取消
|
||||
</button>
|
||||
<button onclick="saveUserPerms()" class="btn btn-primary flex-1 py-3 rounded-xl text-sm font-medium">
|
||||
保存权限
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Global Variables
|
||||
let currentManageUsername = '';
|
||||
let allForms = [];
|
||||
|
||||
// Check Admin Permission
|
||||
async function checkAdmin() {
|
||||
try {
|
||||
const response = await fetch('/api/current_user');
|
||||
const data = await response.json();
|
||||
|
||||
if (!data.logged_in || data.role !== 'admin') {
|
||||
showToast('需要管理员权限', 'error');
|
||||
setTimeout(() => window.location.href = '/admin', 1000);
|
||||
return;
|
||||
}
|
||||
|
||||
loadUsers();
|
||||
} catch (error) {
|
||||
console.error('检查权限失败:', error);
|
||||
window.location.href = '/login?redirect=/user_manage';
|
||||
}
|
||||
}
|
||||
|
||||
// Load Users
|
||||
async function loadUsers() {
|
||||
const loading = document.getElementById('loading');
|
||||
const container = document.getElementById('usersContainer');
|
||||
const empty = document.getElementById('emptyState');
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/user/list');
|
||||
const users = await response.json();
|
||||
|
||||
loading.style.display = 'none';
|
||||
|
||||
if (!users || users.length === 0) {
|
||||
empty.classList.remove('hidden');
|
||||
container.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
|
||||
empty.classList.add('hidden');
|
||||
container.style.display = 'grid';
|
||||
|
||||
container.innerHTML = users.map((user, index) => `
|
||||
<div class="user-card" style="animation-delay: ${index * 0.1}s">
|
||||
<div class="flex justify-between items-start mb-4">
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="w-10 h-10 rounded-full flex items-center justify-center text-sm font-semibold"
|
||||
style="background-color: var(--accent-bg); color: var(--accent-text);">
|
||||
${user.username.charAt(0).toUpperCase()}
|
||||
</div>
|
||||
<div>
|
||||
<h3 class="font-medium text-base theme-transition" style="color: var(--text-primary);">
|
||||
${user.username}
|
||||
</h3>
|
||||
<span class="role-badge role-${user.role}">
|
||||
${user.role === 'admin' ? '管理员' : '普通用户'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-2">
|
||||
${user.role !== 'admin' ? `
|
||||
<button onclick="manageUserForms('${user.username}', '${user.role}')"
|
||||
class="btn btn-manage py-2 px-3 rounded-xl text-xs font-medium">
|
||||
权限
|
||||
</button>
|
||||
` : ''}
|
||||
<button onclick="deleteUser('${user.username}', '${user.role}')"
|
||||
class="btn btn-danger py-2 px-3 rounded-xl text-xs font-medium"
|
||||
${user.username === 'admin' ? 'disabled' : ''}>
|
||||
删除
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pt-4 border-t theme-transition" style="border-color: var(--border-color);">
|
||||
<div class="flex justify-between items-center text-sm">
|
||||
<span class="theme-transition" style="color: var(--text-muted);">创建时间</span>
|
||||
<span class="font-medium theme-transition" style="color: var(--text-secondary);">
|
||||
${formatDate(user.created_at)}
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex justify-between items-center text-sm mt-2">
|
||||
<span class="theme-transition" style="color: var(--text-muted);">管理表单数</span>
|
||||
<span class="font-medium theme-transition" style="color: var(--text-secondary);">
|
||||
${user.managed_forms ? user.managed_forms.length : 0} 个
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`).join('');
|
||||
|
||||
// Animate cards
|
||||
gsap.to(".user-card", {
|
||||
opacity: 1,
|
||||
y: 0,
|
||||
duration: 0.6,
|
||||
stagger: 0.1,
|
||||
ease: "power2.out"
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
loading.style.display = 'none';
|
||||
showToast('加载用户失败: ' + error.message, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// Modal Functions
|
||||
function showAddUserModal() {
|
||||
document.getElementById('newUsername').value = '';
|
||||
document.getElementById('newPassword').value = '';
|
||||
document.getElementById('userRole').value = 'user';
|
||||
document.getElementById('addUserModal').classList.add('show');
|
||||
document.getElementById('addUserModal').style.display = 'flex';
|
||||
}
|
||||
|
||||
function closeAddUserModal() {
|
||||
document.getElementById('addUserModal').classList.remove('show');
|
||||
setTimeout(() => {
|
||||
document.getElementById('addUserModal').style.display = 'none';
|
||||
}, 300);
|
||||
}
|
||||
|
||||
async function addUser() {
|
||||
const username = document.getElementById('newUsername').value.trim();
|
||||
const password = document.getElementById('newPassword').value;
|
||||
const role = document.getElementById('userRole').value;
|
||||
|
||||
if (!username || !password) {
|
||||
showToast('请填写用户名和密码', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
if (username.length < 2) {
|
||||
showToast('用户名至少2个字符', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
if (password.length < 6) {
|
||||
showToast('密码至少6个字符', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/user/add', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ username, password, role })
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
showToast('用户添加成功', 'success');
|
||||
closeAddUserModal();
|
||||
loadUsers();
|
||||
} else {
|
||||
showToast(data.message || '添加失败', 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
showToast('添加失败: ' + error.message, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteUser(username, role) {
|
||||
if (username === 'admin') {
|
||||
showToast('不能删除默认管理员', 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm(`确定要删除用户 "${username}" 吗?`)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/user/delete/${username}`, {
|
||||
method: 'POST'
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
showToast('用户已删除', 'success');
|
||||
loadUsers();
|
||||
} else {
|
||||
showToast(data.message || '删除失败', 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
showToast('删除失败: ' + error.message, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
async function manageUserForms(username, role) {
|
||||
if (role === 'admin') {
|
||||
showToast('管理员可管理所有表单', 'info');
|
||||
return;
|
||||
}
|
||||
|
||||
currentManageUsername = username;
|
||||
document.getElementById('permsUsername').textContent = username;
|
||||
|
||||
try {
|
||||
const [formsResponse, permsResponse] = await Promise.all([
|
||||
fetch('/api/admin/forms'),
|
||||
fetch(`/api/user/${username}/forms`)
|
||||
]);
|
||||
|
||||
const forms = await formsResponse.json();
|
||||
const permsData = await permsResponse.json();
|
||||
|
||||
allForms = forms;
|
||||
const userForms = permsData.managed_forms || [];
|
||||
|
||||
const checkboxesDiv = document.getElementById('formsCheckboxes');
|
||||
|
||||
if (forms.length === 0) {
|
||||
checkboxesDiv.innerHTML = '<div style="color: var(--text-muted); text-align: center; padding: 20px;">暂无表单</div>';
|
||||
} else {
|
||||
checkboxesDiv.innerHTML = forms.map(form => `
|
||||
<label class="checkbox-item">
|
||||
<input type="checkbox" value="${form.id}" ${userForms.includes(form.id) ? 'checked' : ''}>
|
||||
<div class="flex-1 min-w-0">
|
||||
<div class="font-medium truncate" style="color: var(--text-primary);">${form.title}</div>
|
||||
<div class="text-xs" style="color: var(--text-muted);">${form.id}</div>
|
||||
</div>
|
||||
</label>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
document.getElementById('permsModal').classList.add('show');
|
||||
document.getElementById('permsModal').style.display = 'flex';
|
||||
|
||||
} catch (error) {
|
||||
showToast('加载权限失败: ' + error.message, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
function closePermsModal() {
|
||||
document.getElementById('permsModal').classList.remove('show');
|
||||
setTimeout(() => {
|
||||
document.getElementById('permsModal').style.display = 'none';
|
||||
}, 300);
|
||||
}
|
||||
|
||||
async function saveUserPerms() {
|
||||
const checkboxes = document.querySelectorAll('#formsCheckboxes input[type="checkbox"]:checked');
|
||||
const selectedFormIds = Array.from(checkboxes).map(cb => cb.value);
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/user/${currentManageUsername}/forms`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ form_ids: selectedFormIds })
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
showToast('权限已更新', 'success');
|
||||
closePermsModal();
|
||||
loadUsers();
|
||||
} else {
|
||||
showToast(data.message || '保存失败', 'error');
|
||||
}
|
||||
} catch (error) {
|
||||
showToast('保存失败: ' + error.message, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// Utilities
|
||||
function formatDate(dateString) {
|
||||
if (!dateString) return '-';
|
||||
const date = new Date(dateString);
|
||||
return date.toLocaleString('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
});
|
||||
}
|
||||
|
||||
// Close modals on outside click
|
||||
document.querySelectorAll('.modal-overlay').forEach(modal => {
|
||||
modal.addEventListener('click', function(e) {
|
||||
if (e.target === this) {
|
||||
if (this.id === 'addUserModal') closeAddUserModal();
|
||||
if (this.id === 'permsModal') closePermsModal();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Close on ESC
|
||||
document.addEventListener('keydown', function(e) {
|
||||
if (e.key === 'Escape') {
|
||||
closeAddUserModal();
|
||||
closePermsModal();
|
||||
}
|
||||
});
|
||||
|
||||
// Initial Animation
|
||||
window.addEventListener('load', () => {
|
||||
gsap.to("#headerSection", {
|
||||
opacity: 1,
|
||||
y: 0,
|
||||
duration: 0.8,
|
||||
ease: "power2.out",
|
||||
delay: 0.2
|
||||
});
|
||||
});
|
||||
|
||||
// Start
|
||||
window.addEventListener('DOMContentLoaded', checkAdmin);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user