docs(阶段3): 记录出口标准达成;补跑 prettier

覆盖率对账表更新:admin 侧 3/45 已实现,缺口 42。达成判据是 apps/web 的
oj/ 与 shared/ 两个目录已无指向旧 Django 的运行时调用,残留的 utils/http
引用只剩 ApiResponse 这一个类型。

顺带补跑 npm fmt,几个此前未格式化的文件随之改动,均为纯格式。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-07 06:48:20 -06:00
parent 44f6f27841
commit ced8f3ee1b
6 changed files with 50 additions and 26 deletions

View File

@@ -6,16 +6,19 @@ import type {
} from "utils/types" } from "utils/types"
export function getAchievements(name?: string) { export function getAchievements(name?: string) {
return api2.get<any>("achievements", { params: name ? { username: name } : {} }) return api2
.get<any>("achievements", { params: name ? { username: name } : {} })
.then((response) => ({ .then((response) => ({
...response, ...response,
data: { data: {
username: response.data.username, username: response.data.username,
achievements: response.data.achievements.map((item: any): Achievement => ({ achievements: response.data.achievements.map(
...item, (item: any): Achievement => ({
unlock_time: item.unlockTime, ...item,
unlock_rate: item.unlockRate, unlock_time: item.unlockTime,
})), unlock_rate: item.unlockRate,
}),
),
}, },
})) }))
} }

View File

@@ -1,11 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { Icon } from "@iconify/vue" import { Icon } from "@iconify/vue"
import { storeToRefs } from "pinia" import { storeToRefs } from "pinia"
import { import { formatCode, submitCode, updateProblemSetProgress } from "oj/api"
formatCode,
submitCode,
updateProblemSetProgress,
} from "oj/api"
import { useCodeStore } from "oj/store/code" import { useCodeStore } from "oj/store/code"
import { useProblemStore } from "oj/store/problem" import { useProblemStore } from "oj/store/problem"
import { useFireworks } from "oj/problem/composables/useFireworks" import { useFireworks } from "oj/problem/composables/useFireworks"

View File

@@ -45,7 +45,8 @@ export async function getProfile(
class_name: profile.user.className, class_name: profile.user.className,
}, },
real_name: profile.realName ?? "", real_name: profile.realName ?? "",
acm_problems_status: profile.acmProblemsStatus as Profile["acm_problems_status"], acm_problems_status:
profile.acmProblemsStatus as Profile["acm_problems_status"],
avatar: profile.avatar, avatar: profile.avatar,
blog: profile.blog as null, blog: profile.blog as null,
mood: profile.mood ?? "", mood: profile.mood ?? "",

View File

@@ -64,7 +64,6 @@ function submit() {
} }
}) })
} }
</script> </script>
<template> <template>

View File

@@ -61,8 +61,7 @@ export class BaseWebSocket<T extends WebSocketMessage = WebSocketMessage> {
public status: Ref<ConnectionStatus> = ref<ConnectionStatus>("disconnected") public status: Ref<ConnectionStatus> = ref<ConnectionStatus>("disconnected")
constructor(config: WebSocketConfig) { constructor(config: WebSocketConfig) {
this.url = this.url = config.url ?? `${import.meta.env.PUBLIC_WS_URL}/${config.path}/`
config.url ?? `${import.meta.env.PUBLIC_WS_URL}/${config.path}/`
this.maxReconnectAttempts = config.maxReconnectAttempts ?? 5 this.maxReconnectAttempts = config.maxReconnectAttempts ?? 5
this.reconnectDelay = config.reconnectDelay ?? 1000 this.reconnectDelay = config.reconnectDelay ?? 1000

View File

@@ -1,18 +1,45 @@
# 阶段 3 覆盖率对账 # 阶段 3 覆盖率对账
日期2026-08-07 日期2026-08-07首次对账2026-08-07 补记(阶段 3 收口)
基准:`docs/specs/endpoint-inventory.md` 的 110 条 KEEP 端点 基准:`docs/specs/endpoint-inventory.md` 的 110 条 KEEP 端点
对象:`apps/api/src/routes/*.ts` 79 个路由 handler(含未提交工作树) 对象:`apps/api/src/routes/*.ts` 的路由 handler
> ## 状态:阶段 3 出口标准已达成
>
> 出口标准(设计文档第 11 节)是「用户侧全部功能运行在新后端上」。达成判据:
> `apps/web` 里 `oj/` 与 `shared/` 两个目录**已无任何指向旧 Django 的运行时调用**
> 残留的 `utils/http` 引用全是 `import type { ApiResponse }` 这一个类型。
> 仍走旧后端的只剩 `admin/api.ts`85 处)与 `utils/download.ts`,入口都在后台管理界面,属阶段 4。
>
> 收口时补做的三件事:
> 1. 补齐 3 条被用户侧页面调用的 admin 端点(重判 / 提交统计 / 流程图统计),见下表;
> 2. 删除阶段 1 的临时验证物(`GET dev/problems`、`dev-problems.vue`、路由项、`problemSummarySchema`
> 3. 给 `utils/api2.ts` 补上 `login-required` 弹登录框、`permission-denied` 弹提示 ——
> 这两条 `utils/http.ts` 一直有api2 从建包起就漏了,导致此前已迁移的所有端点
> 在鉴权失败时都是「点了没反应」。新加的两个教师专属端点会放大这个问题,故一并补。
>
> 未做:两份评审里的 7 条 Minor 仍未清(见 `phase3-fix-list.md`)。
## 结论 ## 结论
| | 旧端点 KEEP | 新后端已实现 | 缺口 | | | 旧端点 KEEP | 新后端已实现 | 缺口 |
|---|---|---|---| |---|---|---|---|
| **oj 侧** | 65 | 65另有 4 条新增) | **0** | | **oj 侧** | 65 | 65另有 4 条新增) | **0** |
| **admin 侧** | 45 | **0** | **45** | | **admin 侧** | 45 | **3** | **42** |
| 合计 | 110 | 65 | 45 | | 合计 | 110 | 68 | 42 |
**oj 侧已全部覆盖admin 侧一条未做。** 这与设计文档第 11 节的阶段划分一致 —— admin 本就排在阶段 4。 **oj 侧已全部覆盖** admin 侧原计划整块推到阶段 4但其中 3 条被用户侧页面直接调用,
不做完阶段 3 的出口标准(用户侧全部功能跑在新后端上)就不成立,因此在本阶段一并补上:
| 旧端点 | 新路由 | 调用它的用户侧页面 |
|---|---|---|
| `GET admin/submission/rejudge` | `POST submissions/:id/rejudge` | `oj/submission/list.vue` 的重判按钮 |
| `GET admin/submission/statistics` | `GET submissions/statistics` | `StatisticsPanel.vue`(提交列表页 + 题目页) |
| `GET admin/flowchart/statistics` | `GET flowcharts/statistics` | `FlowchartStatisticsPanel.vue`(提交列表页) |
这三条虽然挂在旧后端的 admin 路由下,权限也确实是 `teacher_admin_required` /
`super_admin_required`,但入口在用户侧页面里 —— **「admin 路由」和「admin 页面」不是一回事**
按 URL 前缀切阶段会漏掉它们。剩下 42 条的入口都在后台管理界面,留给阶段 4。
> 对账方法说明:阶段 0 已定案 API 重新设计,新旧路径不同名(如旧 `/api/problem` → 新 `/api/problems`、 > 对账方法说明:阶段 0 已定案 API 重新设计,新旧路径不同名(如旧 `/api/problem` → 新 `/api/problems`、
> 旧 `/api/pickone` → 新 `/api/problems/random`**无法按字符串自动匹配**。本表由人工按语义逐条比对, > 旧 `/api/pickone` → 新 `/api/problems/random`**无法按字符串自动匹配**。本表由人工按语义逐条比对,
@@ -96,9 +123,9 @@
| `PUT submissions/:id` | 判题结果写回 | | `PUT submissions/:id` | 判题结果写回 |
| `POST achievements/pending/read` | 成就已读标记 | | `POST achievements/pending/read` | 成就已读标记 |
| `GET problems/:id/flowchart/history` | 流程图历史 | | `GET problems/:id/flowchart/history` | 流程图历史 |
| `GET dev/problems` | **阶段 1 的临时验证端点,应删除** | | ~~`GET dev/problems`~~ | 阶段 1 的临时验证端点,**已删除**(连同 `dev-problems.vue`、路由与 `problemSummarySchema` |
## admin 侧缺口45 条,按 app ## admin 侧缺口42 条,按 app
| app | 条数 | | app | 条数 |
|---|---| |---|---|
@@ -109,15 +136,14 @@
| tutorial | 3 | | tutorial | 3 |
| account | 2 | | account | 2 |
| achievement | 2 | | achievement | 2 |
| submission | 2 |
| ai | 1 | | ai | 1 |
| announcement | 1 | | announcement | 1 |
| flowchart | 1 |
| utils | 1 | | utils | 1 |
`problem``problemset` 两块占了 24 条,超过 admin 缺口的一半 —— 排期时应作为主体。 `problem``problemset` 两块占了 24 条,超过 admin 缺口的一半 —— 排期时应作为主体。
`submission` 原 2 条、`flowchart` 原 1 条已在本阶段做完,见上方表格。)
## 待处理项 ## 待处理项
1. **`GET dev/problems` 是阶段 1 的临时验证端点**,与 `apps/web` 里的临时验证页 `dev-problems.vue` 配套,两者都应在本阶段收尾时删除 1. 本报告的对照关系带人工判断成分,若某条对应有异议,以实际业务行为为准
2. 本报告的对照关系带人工判断成分,若某条对应有异议,以实际业务行为为准 2. `utils/download.ts` 仍指向旧后端的 `/api/admin`blob 下载),只被 admin 侧两个页面用,随阶段 4 一起切