feat: modernize frontend UI with Tailwind v4 and professional design system

BREAKING CHANGE: Migrated to Tailwind CSS v4 configuration system

Key Changes:
- Migrated from Tailwind v3 to v4 configuration system
  - Removed tailwind.config.js (incompatible with v4)
  - Updated index.css with @theme directive and oklch color space
  - Defined all custom animations directly in CSS using @keyframes

- Redesigned LoginPage with modern, enterprise-grade UI:
  - Full-screen gradient background (blue → purple → pink)
  - Floating animated orbs with blur effects
  - Glass morphism white card with backdrop-blur
  - Gradient buttons with shadow effects
  - 7 custom animations: fade-in, slide-in-right, slide-in-left, scale-in, shimmer, pulse, float

- Added shadcn/ui components:
  - alert.tsx, dialog.tsx, input.tsx, label.tsx, select.tsx, tabs.tsx

- Updated dependencies:
  - Added class-variance-authority ^0.7.0
  - Added react-markdown ^9.0.1

- Updated frontend documentation:
  - Comprehensive README.md with feature list, tech stack, project structure
  - Quick start guide and deployment instructions

Technical Details:
- Tailwind v4 uses @import "tailwindcss" instead of @tailwind directives
- All theme customization now in @theme block with CSS variables
- Color system migrated to oklch for better perceptual uniformity
- Animation definitions moved from config to CSS @layer utilities

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
beabigegg
2025-11-13 08:55:01 +08:00
parent 9cf36d8e21
commit 57cf91271c
12 changed files with 2134 additions and 419 deletions

View File

@@ -3,7 +3,7 @@ import { useNavigate } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import { useAuthStore } from '@/store/authStore'
import { apiClient } from '@/services/api'
import { Lock, User, LayoutDashboard, AlertCircle, Loader2 } from 'lucide-react'
import { Lock, User, LayoutDashboard, AlertCircle, Loader2, Sparkles, Zap, Shield } from 'lucide-react'
export default function LoginPage() {
const { t } = useTranslation()
@@ -21,13 +21,11 @@ export default function LoginPage() {
try {
await apiClient.login({ username, password })
// For now, just set a basic user object (backend doesn't return user info)
setUser({ id: 1, username })
navigate('/upload')
} catch (err: any) {
const errorDetail = err.response?.data?.detail
if (Array.isArray(errorDetail)) {
// Handle validation error array from backend
setError(errorDetail.map((e: any) => e.msg || e.message || String(e)).join(', '))
} else if (typeof errorDetail === 'string') {
setError(errorDetail)
@@ -40,197 +38,194 @@ export default function LoginPage() {
}
return (
<div className="min-h-screen flex">
{/* Left side - Branding (hidden on mobile) */}
<div className="hidden lg:flex lg:flex-1 bg-gradient-to-br from-primary via-primary/90 to-accent relative overflow-hidden">
{/* Subtle background pattern */}
<div className="min-h-screen relative overflow-hidden">
{/* Full-screen Animated Background */}
<div className="absolute inset-0 bg-gradient-to-br from-blue-600 via-purple-600 to-pink-500">
{/* Animated overlay */}
<div className="absolute inset-0 bg-gradient-to-tr from-blue-500/50 via-transparent to-purple-500/50 animate-pulse"></div>
{/* Floating orbs */}
<div className="absolute top-20 left-20 w-72 h-72 bg-white/10 rounded-full blur-3xl animate-float"></div>
<div className="absolute bottom-20 right-20 w-96 h-96 bg-blue-400/20 rounded-full blur-3xl animate-float" style={{ animationDelay: '1s' }}></div>
<div className="absolute top-1/2 left-1/2 w-64 h-64 bg-purple-400/10 rounded-full blur-3xl animate-float" style={{ animationDelay: '0.5s' }}></div>
{/* Grid pattern */}
<div className="absolute inset-0 opacity-10">
<div className="absolute top-0 left-0 w-full h-full"
style={{ backgroundImage: 'radial-gradient(circle at 2px 2px, white 1px, transparent 0)', backgroundSize: '32px 32px' }}>
</div>
</div>
{/* Content */}
<div className="relative z-10 flex flex-col justify-center px-16 py-12 text-white">
{/* Logo & Title */}
<div className="mb-12">
<div className="flex items-center gap-4 mb-4">
<div className="w-14 h-14 bg-white/20 backdrop-blur-sm rounded-xl flex items-center justify-center">
<LayoutDashboard className="w-8 h-8" />
</div>
<div>
<h1 className="text-3xl font-bold">{t('app.title')}</h1>
<p className="text-white/80 text-sm mt-1">{t('app.subtitle')}</p>
</div>
</div>
</div>
{/* Feature highlights */}
<div className="space-y-6 mb-12">
<h2 className="text-2xl font-semibold mb-6"></h2>
<div className="space-y-4">
<div className="flex items-start gap-3">
<div className="w-10 h-10 bg-white/20 backdrop-blur-sm rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5">
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M5 13l4 4L19 7" />
</svg>
</div>
<div>
<h3 className="font-semibold text-lg"></h3>
<p className="text-white/70 text-sm"> 10+ 99%</p>
</div>
</div>
<div className="flex items-start gap-3">
<div className="w-10 h-10 bg-white/20 backdrop-blur-sm rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5">
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M13 10V3L4 14h7v7l9-11h-7z" />
</svg>
</div>
<div>
<h3 className="font-semibold text-lg"></h3>
<p className="text-white/70 text-sm"></p>
</div>
</div>
<div className="flex items-start gap-3">
<div className="w-10 h-10 bg-white/20 backdrop-blur-sm rounded-lg flex items-center justify-center flex-shrink-0 mt-0.5">
<svg className="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z" />
</svg>
</div>
<div>
<h3 className="font-semibold text-lg"></h3>
<p className="text-white/70 text-sm"></p>
</div>
</div>
</div>
</div>
{/* Statistics */}
<div className="grid grid-cols-3 gap-6">
<div className="bg-white/10 backdrop-blur-sm rounded-xl p-4">
<div className="text-3xl font-bold mb-1">99%</div>
<div className="text-white/70 text-sm"></div>
</div>
<div className="bg-white/10 backdrop-blur-sm rounded-xl p-4">
<div className="text-3xl font-bold mb-1">10+</div>
<div className="text-white/70 text-sm"></div>
</div>
<div className="bg-white/10 backdrop-blur-sm rounded-xl p-4">
<div className="text-3xl font-bold mb-1">1M+</div>
<div className="text-white/70 text-sm"></div>
</div>
</div>
<div className="absolute inset-0" style={{ backgroundImage: 'linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px)', backgroundSize: '50px 50px' }}></div>
</div>
</div>
{/* Right side - Login form */}
<div className="flex-1 flex items-center justify-center p-8 bg-background">
<div className="w-full max-w-md">
{/* Mobile logo (shown only on small screens) */}
<div className="lg:hidden text-center mb-8">
<div className="inline-flex items-center gap-3 mb-2">
<div className="w-10 h-10 bg-primary/20 rounded-lg flex items-center justify-center">
<LayoutDashboard className="w-6 h-6 text-primary" />
{/* Content Container */}
<div className="relative z-10 min-h-screen flex items-center justify-center p-4">
<div className="w-full max-w-6xl flex flex-col lg:flex-row gap-8 items-center">
{/* Left Side - Branding */}
<div className="flex-1 text-white text-center lg:text-left animate-fade-in">
{/* Logo */}
<div className="flex items-center justify-center lg:justify-start gap-4 mb-8">
<div className="w-16 h-16 bg-white/20 backdrop-blur-md rounded-2xl flex items-center justify-center shadow-2xl animate-float">
<LayoutDashboard className="w-10 h-10" />
</div>
<div>
<h1 className="text-4xl font-bold tracking-tight">Tool_OCR</h1>
<p className="text-white/80 text-sm mt-1"> OCR </p>
</div>
</div>
{/* Features - Only show on larger screens */}
<div className="hidden lg:block space-y-6 mb-12 animate-slide-in-left" style={{ animationDelay: '0.1s' }}>
<h2 className="text-3xl font-bold mb-8"></h2>
<div className="space-y-4">
<div className="flex items-start gap-4 group hover:translate-x-2 transition-transform">
<div className="w-12 h-12 bg-gradient-to-br from-white/20 to-white/10 backdrop-blur-sm rounded-xl flex items-center justify-center flex-shrink-0 group-hover:scale-110 transition-transform">
<Sparkles className="w-6 h-6" />
</div>
<div>
<h3 className="font-bold text-xl mb-1"></h3>
<p className="text-white/70">AI OCR 99%</p>
</div>
</div>
<div className="flex items-start gap-4 group hover:translate-x-2 transition-transform">
<div className="w-12 h-12 bg-gradient-to-br from-white/20 to-white/10 backdrop-blur-sm rounded-xl flex items-center justify-center flex-shrink-0 group-hover:scale-110 transition-transform">
<Zap className="w-6 h-6" />
</div>
<div>
<h3 className="font-bold text-xl mb-1"></h3>
<p className="text-white/70"></p>
</div>
</div>
<div className="flex items-start gap-4 group hover:translate-x-2 transition-transform">
<div className="w-12 h-12 bg-gradient-to-br from-white/20 to-white/10 backdrop-blur-sm rounded-xl flex items-center justify-center flex-shrink-0 group-hover:scale-110 transition-transform">
<Shield className="w-6 h-6" />
</div>
<div>
<h3 className="font-bold text-xl mb-1"></h3>
<p className="text-white/70"></p>
</div>
</div>
</div>
</div>
{/* Stats */}
<div className="hidden lg:grid grid-cols-3 gap-4 animate-slide-in-left" style={{ animationDelay: '0.2s' }}>
<div className="bg-white/10 backdrop-blur-md rounded-2xl p-6 hover:bg-white/20 hover:scale-105 transition-all cursor-pointer border border-white/20">
<div className="text-4xl font-bold mb-2">99%</div>
<div className="text-white/70 text-sm"></div>
</div>
<div className="bg-white/10 backdrop-blur-md rounded-2xl p-6 hover:bg-white/20 hover:scale-105 transition-all cursor-pointer border border-white/20">
<div className="text-4xl font-bold mb-2">10+</div>
<div className="text-white/70 text-sm"></div>
</div>
<div className="bg-white/10 backdrop-blur-md rounded-2xl p-6 hover:bg-white/20 hover:scale-105 transition-all cursor-pointer border border-white/20">
<div className="text-4xl font-bold mb-2">24/7</div>
<div className="text-white/70 text-sm"></div>
</div>
<h1 className="text-2xl font-bold text-foreground">{t('app.title')}</h1>
</div>
<p className="text-sm text-muted-foreground">{t('app.subtitle')}</p>
</div>
{/* Form card */}
<div className="bg-card rounded-xl border border-border p-8 shadow-lg">
<div className="mb-6">
<h2 className="text-2xl font-bold text-foreground mb-2">{t('auth.loginButton')}</h2>
<p className="text-sm text-muted-foreground"></p>
</div>
<form onSubmit={handleSubmit} className="space-y-5">
{/* Username field */}
<div className="space-y-2">
<label htmlFor="username" className="block text-sm font-medium text-foreground">
{t('auth.username')}
</label>
<div className="relative">
<div className="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<User className="h-5 w-5 text-muted-foreground" />
</div>
<input
id="username"
type="text"
value={username}
onChange={(e) => setUsername(e.target.value)}
className="w-full pl-10 pr-4 py-2.5 bg-background border border-border rounded-lg
text-foreground placeholder-muted-foreground
focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary
transition-colors"
placeholder="輸入用戶名"
required
/>
</div>
{/* Right Side - Login Form */}
<div className="w-full lg:w-auto lg:min-w-[480px] animate-scale-in">
<div className="bg-white/95 backdrop-blur-xl rounded-3xl p-8 md:p-10 shadow-2xl border border-white/20">
<div className="mb-8">
<h2 className="text-3xl font-bold text-gray-900 mb-2"></h2>
<p className="text-gray-600">使 OCR </p>
</div>
{/* Password field */}
<div className="space-y-2">
<label htmlFor="password" className="block text-sm font-medium text-foreground">
{t('auth.password')}
</label>
<div className="relative">
<div className="absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none">
<Lock className="h-5 w-5 text-muted-foreground" />
<form onSubmit={handleSubmit} className="space-y-6">
{/* Username */}
<div className="space-y-2 animate-slide-in-right" style={{ animationDelay: '0.1s' }}>
<label htmlFor="username" className="block text-sm font-semibold text-gray-700">
使
</label>
<div className="relative group">
<div className="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
<User className="h-5 w-5 text-gray-400 group-focus-within:text-blue-600 transition-colors" />
</div>
<input
id="username"
type="text"
value={username}
onChange={(e) => setUsername(e.target.value)}
className="w-full pl-11 pr-4 py-3 bg-gray-50 border-2 border-gray-200 rounded-xl
text-gray-900 placeholder-gray-400
focus:outline-none focus:ring-4 focus:ring-blue-500/20 focus:border-blue-500
hover:border-gray-300
transition-all duration-200"
placeholder="輸入您的用戶名"
required
/>
</div>
<input
id="password"
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
className="w-full pl-10 pr-4 py-2.5 bg-background border border-border rounded-lg
text-foreground placeholder-muted-foreground
focus:outline-none focus:ring-2 focus:ring-primary/20 focus:border-primary
transition-colors"
placeholder="輸入密碼"
required
/>
</div>
</div>
{/* Error message */}
{error && (
<div className="flex items-start gap-3 p-4 bg-destructive/10 border border-destructive/30 rounded-lg">
<AlertCircle className="h-5 w-5 text-destructive flex-shrink-0 mt-0.5" />
<p className="text-sm text-destructive">{error}</p>
{/* Password */}
<div className="space-y-2 animate-slide-in-right" style={{ animationDelay: '0.2s' }}>
<label htmlFor="password" className="block text-sm font-semibold text-gray-700">
</label>
<div className="relative group">
<div className="absolute inset-y-0 left-0 pl-4 flex items-center pointer-events-none">
<Lock className="h-5 w-5 text-gray-400 group-focus-within:text-blue-600 transition-colors" />
</div>
<input
id="password"
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
className="w-full pl-11 pr-4 py-3 bg-gray-50 border-2 border-gray-200 rounded-xl
text-gray-900 placeholder-gray-400
focus:outline-none focus:ring-4 focus:ring-blue-500/20 focus:border-blue-500
hover:border-gray-300
transition-all duration-200"
placeholder="輸入您的密碼"
required
/>
</div>
</div>
)}
{/* Submit button */}
<button
type="submit"
disabled={loading}
className="w-full py-3 px-6 bg-primary text-white rounded-lg font-semibold
shadow-md hover:bg-primary-hover hover:shadow-lg
focus:outline-none focus:ring-2 focus:ring-primary/20 focus:ring-offset-2
disabled:opacity-50 disabled:cursor-not-allowed
transition-all duration-200
flex items-center justify-center gap-2"
>
{loading ? (
<>
<Loader2 className="w-5 h-5 animate-spin" />
<span>{t('common.loading')}</span>
</>
) : (
<span>{t('auth.loginButton')}</span>
{/* Error */}
{error && (
<div className="flex items-start gap-3 p-4 bg-red-50 border-2 border-red-200 rounded-xl animate-scale-in">
<AlertCircle className="h-5 w-5 text-red-600 flex-shrink-0 mt-0.5" />
<p className="text-sm text-red-600 font-medium">{error}</p>
</div>
)}
</button>
</form>
{/* Footer */}
<div className="mt-6 text-center">
<p className="text-xs text-muted-foreground">
Powered by <span className="font-semibold text-foreground">AI Technology</span>
</p>
{/* Submit Button */}
<button
type="submit"
disabled={loading}
className="w-full py-4 px-6 bg-gradient-to-r from-blue-600 to-purple-600 text-white rounded-xl font-bold text-lg
shadow-lg shadow-blue-500/50 hover:shadow-xl hover:shadow-blue-500/60 hover:scale-[1.02]
focus:outline-none focus:ring-4 focus:ring-blue-500/50
disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:scale-100
transition-all duration-200
relative overflow-hidden group
animate-slide-in-right"
style={{ animationDelay: '0.3s' }}
>
<div className="absolute inset-0 bg-gradient-to-r from-blue-700 to-purple-700 opacity-0 group-hover:opacity-100 transition-opacity"></div>
<span className="relative flex items-center justify-center gap-2">
{loading ? (
<>
<Loader2 className="w-6 h-6 animate-spin" />
<span>...</span>
</>
) : (
<span></span>
)}
</span>
</button>
</form>
{/* Footer */}
<div className="mt-8 text-center animate-fade-in" style={{ animationDelay: '0.4s' }}>
<p className="text-xs text-gray-500">
Powered by <span className="font-bold text-gray-700">AI Technology</span>
</p>
</div>
</div>
</div>
</div>