File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import {
1515 ChevronLeft ,
1616 ChevronRight ,
1717 RefreshCw ,
18+ Eye ,
1819} from 'lucide-react' ;
1920import toast from 'react-hot-toast' ;
2021import api from '../services/api' ;
@@ -75,6 +76,7 @@ export default function ProblemDetail() {
7576
7677 // Hint panel
7778 const [ hintExpanded , setHintExpanded ] = useState ( true ) ;
79+ const [ showSolution , setShowSolution ] = useState ( false ) ;
7880
7981 const CODE_SAVE_KEY = `cj_code_${ id } _${ language } ` ;
8082
@@ -490,6 +492,24 @@ export default function ProblemDetail() {
490492 < MarkdownRenderer content = { problem . description } />
491493 </ div >
492494
495+ { /* Solution */ }
496+ { problem . user_passed && problem . solution && (
497+ < div className = "card p-6 mb-6 border-primary-500/20" >
498+ < button
499+ onClick = { ( ) => setShowSolution ( ! showSolution ) }
500+ className = "flex items-center gap-2 text-sm font-medium text-primary-400 hover:text-primary-300 transition-colors"
501+ >
502+ < Eye size = { 16 } />
503+ { showSolution ? '隐藏参考答案' : '查看参考答案' }
504+ </ button >
505+ { showSolution && (
506+ < div className = "mt-4 p-4 bg-dark-800/50 rounded-lg border border-dark-700" >
507+ < MarkdownRenderer content = { problem . solution } />
508+ </ div >
509+ ) }
510+ </ div >
511+ ) }
512+
493513 { /* Submission area */ }
494514 < div className = "card p-6 mb-6" >
495515 < h2 className = "text-lg font-semibold text-white mb-4" >
You can’t perform that action at this time.
0 commit comments