mirror of
https://github.com/handsomezhuzhu/QQuiz.git
synced 2026-02-20 12:00:14 +00:00
## 功能特性 ✅ **核心功能** - 多文件上传与智能去重(基于 content_hash) - 异步文档解析(支持 TXT/PDF/DOCX/XLSX) - AI 智能题目提取与评分(OpenAI/Anthropic/Qwen) - 断点续做与进度管理 - 自动错题本收集 ✅ **技术栈** - Backend: FastAPI + SQLAlchemy 2.0 + PostgreSQL - Frontend: React 18 + Vite + Tailwind CSS - Deployment: Docker Compose ✅ **项目结构** - 53 个文件 - 完整的前后端分离架构 - Docker/源码双模部署支持 🚀 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
29 lines
661 B
JavaScript
29 lines
661 B
JavaScript
/**
|
|
* Protected Route Component
|
|
*/
|
|
import React from 'react'
|
|
import { Navigate } from 'react-router-dom'
|
|
import { useAuth } from '../context/AuthContext'
|
|
|
|
export const ProtectedRoute = ({ children, adminOnly = false }) => {
|
|
const { user, loading } = useAuth()
|
|
|
|
if (loading) {
|
|
return (
|
|
<div className="min-h-screen flex items-center justify-center">
|
|
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-primary-600"></div>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
if (!user) {
|
|
return <Navigate to="/login" replace />
|
|
}
|
|
|
|
if (adminOnly && !user.is_admin) {
|
|
return <Navigate to="/dashboard" replace />
|
|
}
|
|
|
|
return children
|
|
}
|