Skip to content

Commit c231c2c

Browse files
author
CodeJudge
committed
feat: 难度颜色标签 + 提交结果再来一次
1 parent 8886e23 commit c231c2c

2 files changed

Lines changed: 33 additions & 15 deletions

File tree

frontend/src/pages/ProblemDetail.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
ChevronUp,
1515
ChevronLeft,
1616
ChevronRight,
17+
RefreshCw,
1718
} from 'lucide-react';
1819
import toast from 'react-hot-toast';
1920
import api from '../services/api';
@@ -346,6 +347,13 @@ export default function ProblemDetail() {
346347
)}
347348
</div>
348349
)}
350+
351+
<button
352+
onClick={() => { setSubmissionResult(null); window.scrollTo(0, 0); }}
353+
className="mt-4 text-sm text-primary-400 hover:text-primary-300 transition-colors inline-flex items-center gap-1"
354+
>
355+
<RefreshCw size={14} /> 再来一次
356+
</button>
349357
</div>
350358
);
351359
};

frontend/src/pages/Problems.tsx

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -304,21 +304,31 @@ export default function Problems() {
304304
</div>
305305

306306
<div className="flex gap-1">
307-
{difficultyOptions.map((opt) => (
308-
<button
309-
key={opt.value}
310-
onClick={() =>
311-
updateParams({ difficulty: opt.value, page: '' })
312-
}
313-
className={`px-3 py-1.5 rounded-md text-sm transition-colors ${
314-
difficulty === opt.value
315-
? 'bg-blue-600 text-white'
316-
: 'bg-dark-800 text-gray-300 hover:bg-dark-700'
317-
}`}
318-
>
319-
{opt.label}
320-
</button>
321-
))}
307+
{difficultyOptions.map((opt) => {
308+
const active = difficulty === opt.value;
309+
const colorMap: Record<string, string> = {
310+
easy: active ? 'bg-green-600 text-white' : 'text-green-500 border-green-500/30 bg-green-500/5 hover:bg-green-500/15',
311+
medium: active ? 'bg-yellow-600 text-white' : 'text-yellow-500 border-yellow-500/30 bg-yellow-500/5 hover:bg-yellow-500/15',
312+
hard: active ? 'bg-red-600 text-white' : 'text-red-500 border-red-500/30 bg-red-500/5 hover:bg-red-500/15',
313+
};
314+
return (
315+
<button
316+
key={opt.value}
317+
onClick={() =>
318+
updateParams({ difficulty: opt.value, page: '' })
319+
}
320+
className={`px-3 py-1.5 rounded-md text-sm transition-colors ${
321+
active && !['easy','medium','hard'].includes(opt.value)
322+
? 'bg-blue-600 text-white'
323+
: ''
324+
} ${
325+
active ? '' : (!opt.value ? 'bg-dark-800 text-gray-300 hover:bg-dark-700' : 'border')
326+
} ${opt.value && colorMap[opt.value] ? colorMap[opt.value] : ''}`}
327+
>
328+
{opt.label}
329+
</button>
330+
);
331+
})}
322332
</div>
323333

324334
<button

0 commit comments

Comments
 (0)