Skip to content

Commit 70ee574

Browse files
author
CodeJudge
committed
feat: AC庆祝动画 + 已通过徽章 + 页面标题
1 parent a8cf008 commit 70ee574

8 files changed

Lines changed: 36 additions & 3 deletions

File tree

frontend/src/components/ProblemCard.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,15 @@ export default function ProblemCard({ problem }: { problem: Problem }) {
4545
return (
4646
<Link
4747
to={`/problems/${problem.id}`}
48-
className="card flex flex-col gap-4 hover:border-primary-500/50 hover:-translate-y-0.5 hover:shadow-lg hover:shadow-primary-500/5 transition-all duration-200 group"
48+
className={`card flex flex-col gap-4 hover:border-primary-500/50 hover:-translate-y-0.5 hover:shadow-lg hover:shadow-primary-500/5 transition-all duration-200 group${problem.user_passed ? ' border-l-emerald-500' : ''}`}
4949
>
5050
<div className="flex items-start justify-between gap-3">
5151
<div className="flex items-center gap-2.5 min-w-0">
5252
{problem.user_passed && (
53-
<CheckCircle2 className="w-5 h-5 text-emerald-500 flex-shrink-0" />
53+
<span className="inline-flex items-center gap-1 px-2 py-0.5 bg-emerald-500/15 text-emerald-400 text-xs rounded-full border border-emerald-500/30 flex-shrink-0">
54+
<CheckCircle2 className="w-3.5 h-3.5" />
55+
已通过
56+
</span>
5457
)}
5558
<h3 className="text-lg font-semibold text-white truncate group-hover:text-primary-400 transition-colors">
5659
{problem.title}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { useEffect } from 'react';
2+
3+
export function useDocumentTitle(title: string) {
4+
useEffect(() => {
5+
const prev = document.title;
6+
document.title = title ? `${title} - CodeJudge` : 'CodeJudge';
7+
return () => { document.title = prev; };
8+
}, [title]);
9+
}

frontend/src/pages/Home.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Link } from 'react-router-dom';
33
import { Code2, ListChecks, PenLine, ArrowRight, BookOpen, Sparkles, Zap, Flame, Calendar } from 'lucide-react';
44
import { useAuth } from '../context/AuthContext';
55
import api from '../services/api';
6+
import { useDocumentTitle } from '../hooks/useDocumentTitle';
67
import ProblemCard from '../components/ProblemCard';
78
import type { ProblemStats, Problem } from '../types';
89

@@ -40,6 +41,7 @@ const statDefs = [
4041
];
4142

4243
export default function Home() {
44+
useDocumentTitle('首页');
4345
const { user } = useAuth();
4446
const [stats, setStats] = useState<ProblemStats | null>(null);
4547
const [recentProblems, setRecentProblems] = useState<Problem[]>([]);

frontend/src/pages/Leaderboard.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useState, useEffect } from 'react';
22
import { Trophy, Medal, User as UserIcon, Zap, BarChart3 } from 'lucide-react';
33
import api from '../services/api';
4+
import { useDocumentTitle } from '../hooks/useDocumentTitle';
45

56
interface LeaderboardEntry {
67
rank: number;
@@ -12,6 +13,7 @@ interface LeaderboardEntry {
1213
}
1314

1415
export default function Leaderboard() {
16+
useDocumentTitle('排行榜');
1517
const [entries, setEntries] = useState<LeaderboardEntry[]>([]);
1618
const [loading, setLoading] = useState(true);
1719
const [error, setError] = useState<string | null>(null);

frontend/src/pages/ProblemDetail.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
Loader2,
99
Share2,
1010
Star,
11+
Sparkles,
1112
} from 'lucide-react';
1213
import toast from 'react-hot-toast';
1314
import api from '../services/api';
@@ -18,6 +19,7 @@ import SubmissionStatus from '../components/SubmissionStatus';
1819
import MarkdownRenderer from '../components/MarkdownRenderer';
1920
import type { Problem, Submission, TestCaseResult } from '../types';
2021
import { useBookmarks } from '../context/BookmarkContext';
22+
import { useDocumentTitle } from '../hooks/useDocumentTitle';
2123

2224
const DIFFICULTY_LABELS: Record<string, string> = {
2325
easy: '简单',
@@ -187,6 +189,15 @@ export default function ProblemDetail() {
187189

188190
return (
189191
<div className="card p-6 mt-6">
192+
{submissionResult.status === 'accepted' && (
193+
<div className="mb-4 p-4 bg-emerald-500/10 border border-emerald-500/30 rounded-lg flex items-center gap-3">
194+
<Sparkles className="w-6 h-6 text-emerald-400" />
195+
<div>
196+
<p className="text-emerald-400 font-semibold text-lg">🎉 恭喜通过!</p>
197+
<p className="text-emerald-500/70 text-sm">太棒了,继续加油!</p>
198+
</div>
199+
</div>
200+
)}
190201
<h3 className="text-lg font-semibold text-white mb-4 flex items-center gap-2">
191202
判题结果
192203
<SubmissionStatus
@@ -329,6 +340,8 @@ export default function ProblemDetail() {
329340
? problem.tags.split(',').filter(Boolean)
330341
: [];
331342

343+
useDocumentTitle(problem?.title || '题目');
344+
332345
return (
333346
<div>
334347
<Link

frontend/src/pages/Problems.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import api from '../services/api';
2020
import ProblemCard from '../components/ProblemCard';
2121
import type { Problem, PaginatedResponse, ProblemStats } from '../types';
2222
import { useBookmarks } from '../context/BookmarkContext';
23+
import { useDocumentTitle } from '../hooks/useDocumentTitle';
2324

2425
const typeOptions = [
2526
{ label: '全部', value: '' },
@@ -38,6 +39,7 @@ const difficultyOptions = [
3839
const PAGE_SIZE_OPTIONS = [10, 20, 50];
3940

4041
export default function Problems() {
42+
useDocumentTitle('题库');
4143
const [searchParams, setSearchParams] = useSearchParams();
4244

4345
const search = searchParams.get('search') || '';

frontend/src/pages/Profile.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { User, Mail, Shield, Award, TrendingUp, Loader2, AlertTriangle, CheckCir
44
import { useAuth } from '../context/AuthContext';
55
import api from '../services/api';
66
import type { Submission } from '../types';
7+
import { useDocumentTitle } from '../hooks/useDocumentTitle';
78

89
const STATUS_MAP: Record<string, { label: string; icon: React.ReactNode; className: string }> = {
910
accepted: {
@@ -34,6 +35,7 @@ const STATUS_MAP: Record<string, { label: string; icon: React.ReactNode; classNa
3435
};
3536

3637
export default function Profile() {
38+
useDocumentTitle('个人中心');
3739
const { user } = useAuth();
3840
const [profile, setProfile] = useState<any>(null);
3941
const [submissions, setSubmissions] = useState<Submission[]>([]);

frontend/tsconfig.tsbuildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"root":["./src/app.tsx","./src/main.tsx","./src/components/choicequestion.tsx","./src/components/codeeditor.tsx","./src/components/fillblankquestion.tsx","./src/components/footer.tsx","./src/components/markdownrenderer.tsx","./src/components/navbar.tsx","./src/components/problemcard.tsx","./src/components/submissionstatus.tsx","./src/context/authcontext.tsx","./src/context/bookmarkcontext.tsx","./src/pages/admin.tsx","./src/pages/adminproblemform.tsx","./src/pages/home.tsx","./src/pages/leaderboard.tsx","./src/pages/login.tsx","./src/pages/notfound.tsx","./src/pages/problemdetail.tsx","./src/pages/problems.tsx","./src/pages/profile.tsx","./src/pages/register.tsx","./src/pages/submissions.tsx","./src/services/api.ts","./src/types/index.ts"],"version":"5.9.3"}
1+
{"root":["./src/app.tsx","./src/main.tsx","./src/components/choicequestion.tsx","./src/components/codeeditor.tsx","./src/components/fillblankquestion.tsx","./src/components/footer.tsx","./src/components/markdownrenderer.tsx","./src/components/navbar.tsx","./src/components/problemcard.tsx","./src/components/submissionstatus.tsx","./src/context/authcontext.tsx","./src/context/bookmarkcontext.tsx","./src/hooks/usedocumenttitle.ts","./src/pages/admin.tsx","./src/pages/adminproblemform.tsx","./src/pages/home.tsx","./src/pages/leaderboard.tsx","./src/pages/login.tsx","./src/pages/notfound.tsx","./src/pages/problemdetail.tsx","./src/pages/problems.tsx","./src/pages/profile.tsx","./src/pages/register.tsx","./src/pages/submissions.tsx","./src/services/api.ts","./src/types/index.ts"],"version":"5.9.3"}

0 commit comments

Comments
 (0)