@@ -7,10 +7,13 @@ import {
77 Save ,
88 Loader2 ,
99 AlertTriangle ,
10+ Eye ,
11+ EyeOff ,
1012} from 'lucide-react' ;
1113import toast from 'react-hot-toast' ;
1214import api from '../services/api' ;
1315import type { Problem } from '../types' ;
16+ import MarkdownRenderer from '../components/MarkdownRenderer' ;
1417
1518interface TestCase {
1619 input : string ;
@@ -37,6 +40,7 @@ export default function AdminProblemForm() {
3740 const [ loading , setLoading ] = useState ( false ) ;
3841 const [ saving , setSaving ] = useState ( false ) ;
3942 const [ fetchError , setFetchError ] = useState < string | null > ( null ) ;
43+ const [ showPreview , setShowPreview ] = useState ( false ) ;
4044
4145 // Form fields
4246 const [ title , setTitle ] = useState ( '' ) ;
@@ -309,10 +313,23 @@ export default function AdminProblemForm() {
309313 < textarea
310314 value = { description }
311315 onChange = { ( e ) => setDescription ( e . target . value ) }
312- placeholder = "请输入题目描述(支持 HTML)"
316+ placeholder = "请输入题目描述(支持 HTML 和 Markdown )"
313317 rows = { 6 }
314318 className = "input w-full resize-y"
315319 />
320+ < button
321+ type = "button"
322+ onClick = { ( ) => setShowPreview ( ! showPreview ) }
323+ className = "mt-1 text-xs text-dark-400 hover:text-white transition-colors inline-flex items-center gap-1"
324+ >
325+ { showPreview ? < EyeOff size = { 12 } /> : < Eye size = { 12 } /> }
326+ { showPreview ? '关闭预览' : '预览' }
327+ </ button >
328+ { showPreview && description && (
329+ < div className = "mt-2 p-4 bg-dark-800/50 rounded-lg border border-dark-700" >
330+ < MarkdownRenderer content = { description } />
331+ </ div >
332+ ) }
316333 </ div >
317334
318335 { /* Type */ }
0 commit comments