Skip to content

Commit 585490c

Browse files
author
CodeJudge
committed
feat: 移动端适配 + CI工作流
1 parent 0a4c3bd commit 585490c

3 files changed

Lines changed: 38 additions & 11 deletions

File tree

.github/workflows/ci.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: CI
2+
on: [push, pull_request]
3+
4+
jobs:
5+
lint-and-test:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/checkout@v4
9+
- uses: actions/setup-node@v4
10+
with:
11+
node-version: 20
12+
- name: Install backend dependencies
13+
run: cd backend && npm ci
14+
- name: Install frontend dependencies
15+
run: cd frontend && npm ci
16+
- name: TypeScript check
17+
run: cd frontend && npx tsc -b --noEmit
18+
- name: Frontend build
19+
run: cd frontend && npx vite build
20+
- name: Start server and run tests
21+
run: |
22+
cd backend
23+
node src/app.js &
24+
sleep 3
25+
node --test tests/*.test.js
26+
env:
27+
CI: true

frontend/src/pages/Admin.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export default function Admin() {
170170

171171
{/* Admin Analytics */}
172172
{adminStats && (
173-
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 mb-8">
173+
<div className="grid grid-cols-2 sm:grid-cols-4 gap-4 mb-8">
174174
<div className="card p-5 flex items-center gap-4">
175175
<div className="p-3 bg-indigo-600/20 rounded-lg">
176176
<Users size={24} className="text-indigo-400" />
@@ -254,14 +254,14 @@ export default function Admin() {
254254
<p className="text-gray-400">暂无题目,点击上方按钮创建</p>
255255
</div>
256256
) : (
257-
<div className="card overflow-hidden">
257+
<div className="card overflow-x-auto">
258258
<table className="w-full text-sm">
259259
<thead>
260260
<tr className="border-b border-dark-700">
261-
<th className="text-left py-3 px-4 text-gray-400">ID</th>
261+
<th className="text-left py-3 px-4 text-gray-400 hidden md:table-cell">ID</th>
262262
<th className="text-left py-3 px-4 text-gray-400">标题</th>
263263
<th className="text-left py-3 px-4 text-gray-400">类型</th>
264-
<th className="text-left py-3 px-4 text-gray-400">难度</th>
264+
<th className="text-left py-3 px-4 text-gray-400 hidden md:table-cell">难度</th>
265265
<th className="text-right py-3 px-4 text-gray-400">操作</th>
266266
</tr>
267267
</thead>
@@ -271,7 +271,7 @@ export default function Admin() {
271271
key={problem.id}
272272
className="border-b border-dark-800 hover:bg-dark-800/50 transition-colors"
273273
>
274-
<td className="py-3 px-4 text-gray-400">{problem.id}</td>
274+
<td className="py-3 px-4 text-gray-400 hidden md:table-cell">{problem.id}</td>
275275
<td className="py-3 px-4 text-white font-medium">
276276
{problem.title}
277277
</td>
@@ -280,7 +280,7 @@ export default function Admin() {
280280
{TYPE_LABELS[problem.type] || problem.type}
281281
</span>
282282
</td>
283-
<td className="py-3 px-4">
283+
<td className="py-3 px-4 hidden md:table-cell">
284284
<span
285285
className={`px-2 py-0.5 text-xs rounded text-white ${
286286
DIFFICULTY_COLORS[problem.difficulty] || 'bg-gray-600'
@@ -291,7 +291,7 @@ export default function Admin() {
291291
</span>
292292
</td>
293293
<td className="py-3 px-4 text-right">
294-
<div className="flex items-center justify-end gap-1">
294+
<div className="flex flex-col md:flex-row items-end md:items-center justify-end gap-1">
295295
<button
296296
onClick={() =>
297297
navigate(`/admin/problems/${problem.id}/edit`)

frontend/src/pages/Leaderboard.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ export default function Leaderboard() {
6666
<th className="text-left py-3 px-4 text-dark-400 text-sm font-medium w-16">排名</th>
6767
<th className="text-left py-3 px-4 text-dark-400 text-sm font-medium">用户</th>
6868
<th className="text-center py-3 px-4 text-dark-400 text-sm font-medium">通过题数</th>
69-
<th className="text-center py-3 px-4 text-dark-400 text-sm font-medium">通过率</th>
70-
<th className="text-center py-3 px-4 text-dark-400 text-sm font-medium">总提交</th>
69+
<th className="text-center py-3 px-4 text-dark-400 text-sm font-medium hidden md:table-cell">通过率</th>
70+
<th className="text-center py-3 px-4 text-dark-400 text-sm font-medium hidden md:table-cell">总提交</th>
7171
</tr>
7272
</thead>
7373
<tbody>
@@ -103,7 +103,7 @@ export default function Leaderboard() {
103103
</td>
104104
<td className="py-3 px-4 text-center">
105105
<div className="flex items-center justify-center gap-2">
106-
<div className="w-16 h-1.5 bg-dark-700 rounded-full overflow-hidden">
106+
<div className="w-16 h-1.5 bg-dark-700 rounded-full overflow-hidden hidden md:block">
107107
<div
108108
className="h-full bg-primary-500 rounded-full transition-all"
109109
style={{ width: `${passRate}%` }}
@@ -112,7 +112,7 @@ export default function Leaderboard() {
112112
<span className="text-dark-400 text-xs">{passRate}%</span>
113113
</div>
114114
</td>
115-
<td className="py-3 px-4 text-center text-dark-400">
115+
<td className="py-3 px-4 text-center text-dark-400 hidden md:table-cell">
116116
{entry.total_submissions}
117117
</td>
118118
</tr>

0 commit comments

Comments
 (0)