原来只有 `apps/web` 在 Prettier 下(配置在 `apps/web/.prettierrc.toml`、脚本在 web 的 package.json),后端和契约从来没格式化过 —— 手写在 100 列上下,`db/schema.ts` 还是 drizzle-kit pull 留下的 tab 缩进。两套口径分叉久了,跨端改一处就得记着「这边 什么风格」。 - 配置搬到根目录 `.prettierrc.toml`,内容不变(`semi=false`,其余全默认, printWidth 80 —— 和前端已有的格式一致,不另立一套宽度); - 脚本统一成根目录 `bun run fmt`,覆盖 `apps/*/src`、`apps/web/tests` 和两个构建 配置;web 自己那份 `fmt` 和重复的 prettier 依赖删掉; - `.prettierignore` 挡掉两类不该碰的:drizzle-kit 生成的 `src/db/meta/` 结构快照 (它是 db:generate 的比对输入,只该由 drizzle-kit 写)、unplugin 每次 dev 都会 重写的 `auto-imports.d.ts` / `components.d.ts`; - 全量跑了一遍。纯格式,无行为改动:api typecheck / check:routes / check:ast、 前端 type-check 全过,起 api 打了接口确认正常。前端这 39 个文件的小改动是 prettier 版本漂移(类型断言的换行口径变了),不是新配置带来的。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -41,7 +41,5 @@ export function getHitokoto() {
|
||||
}
|
||||
|
||||
export function getClassUsernames(classroom: string) {
|
||||
return api.get<string[]>(
|
||||
`classes/${encodeURIComponent(classroom)}/usernames`,
|
||||
)
|
||||
return api.get<string[]>(`classes/${encodeURIComponent(classroom)}/usernames`)
|
||||
}
|
||||
|
||||
@@ -158,7 +158,10 @@
|
||||
import { formatISO, sub, type Duration } from "date-fns"
|
||||
import type { FlowchartStatistics } from "@oj2/contract"
|
||||
import { getFlowchartStatistics } from "oj/api"
|
||||
import { PANEL_DURATION_OPTIONS, FLOWCHART_CRITERIA_ORDER } from "utils/constants"
|
||||
import {
|
||||
PANEL_DURATION_OPTIONS,
|
||||
FLOWCHART_CRITERIA_ORDER,
|
||||
} from "utils/constants"
|
||||
import { durationFromValue } from "utils/functions"
|
||||
import { useHiddenStudents } from "../composables/hiddenStudents"
|
||||
import { Doughnut, Radar, Bar } from "vue-chartjs"
|
||||
@@ -471,7 +474,8 @@ function renderWordCloud() {
|
||||
|
||||
const subOptions = computed<Duration>(
|
||||
() =>
|
||||
durationFromValue(query.duration) ?? durationFromValue(PANEL_DURATION_OPTIONS[0].value)!,
|
||||
durationFromValue(query.duration) ??
|
||||
durationFromValue(PANEL_DURATION_OPTIONS[0].value)!,
|
||||
)
|
||||
|
||||
async function handleStatistics() {
|
||||
|
||||
@@ -249,19 +249,23 @@ const ATTEMPT_COLORS: Record<string, string> = {
|
||||
* 已通过的沉底,它们只是「做完了」,不需要再看。
|
||||
*/
|
||||
function groupByProblem(list: SubmissionStatisticsItems["items"]) {
|
||||
const groups = new Map<string, {
|
||||
problem: string
|
||||
problemTitle: string
|
||||
items: SubmissionStatisticsItems["items"]
|
||||
}>()
|
||||
const groups = new Map<
|
||||
string,
|
||||
{
|
||||
problem: string
|
||||
problemTitle: string
|
||||
items: SubmissionStatisticsItems["items"]
|
||||
}
|
||||
>()
|
||||
for (const item of list) {
|
||||
const group = groups.get(item.problem)
|
||||
if (group) group.items.push(item)
|
||||
else groups.set(item.problem, {
|
||||
problem: item.problem,
|
||||
problemTitle: item.problemTitle,
|
||||
items: [item],
|
||||
})
|
||||
else
|
||||
groups.set(item.problem, {
|
||||
problem: item.problem,
|
||||
problemTitle: item.problemTitle,
|
||||
items: [item],
|
||||
})
|
||||
}
|
||||
return [...groups.values()]
|
||||
.map((group) => ({
|
||||
@@ -276,8 +280,9 @@ function groupByProblem(list: SubmissionStatisticsItems["items"]) {
|
||||
item.result === SubmissionStatus.ast_check_failed,
|
||||
),
|
||||
}))
|
||||
.sort((a, b) =>
|
||||
Number(a.solved) - Number(b.solved) || b.items.length - a.items.length,
|
||||
.sort(
|
||||
(a, b) =>
|
||||
Number(a.solved) - Number(b.solved) || b.items.length - a.items.length,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -298,9 +303,18 @@ const columns: DataTableColumn<SubmissionStatisticsUser>[] = [
|
||||
h(NFlex, { size: "small", align: "flex-start", wrap: false }, () => [
|
||||
h(
|
||||
NFlex,
|
||||
{ size: 4, align: "center", wrap: false, style: "width: 200px; flex: none" },
|
||||
{
|
||||
size: 4,
|
||||
align: "center",
|
||||
wrap: false,
|
||||
style: "width: 200px; flex: none",
|
||||
},
|
||||
() => [
|
||||
h(NTag, { size: "small", bordered: false }, () => group.problem),
|
||||
h(
|
||||
NTag,
|
||||
{ size: "small", bordered: false },
|
||||
() => group.problem,
|
||||
),
|
||||
h(
|
||||
NText,
|
||||
{
|
||||
@@ -318,39 +332,46 @@ const columns: DataTableColumn<SubmissionStatisticsUser>[] = [
|
||||
depth: 3,
|
||||
style: "width: 104px; flex: none",
|
||||
},
|
||||
() => `${group.items.length} 次 · ${group.solved ? "已通过" : "未通过"}`,
|
||||
() =>
|
||||
`${group.items.length} 次 · ${group.solved ? "已通过" : "未通过"}`,
|
||||
),
|
||||
h(NFlex, { size: 4, wrap: true, style: "flex: 1; min-width: 0" }, () =>
|
||||
group.items.map((item) =>
|
||||
h(
|
||||
NTooltip,
|
||||
{ delay: 200 },
|
||||
{
|
||||
trigger: () =>
|
||||
h("button", {
|
||||
// 内联样式而不是 class:这些方块是 h() 出来、挂在 NDataTable 的
|
||||
// 展开槽里渲染的,<style scoped> 能不能盖到它并不确定
|
||||
style: {
|
||||
width: "14px",
|
||||
height: "14px",
|
||||
padding: "0",
|
||||
border: "none",
|
||||
borderRadius: "3px",
|
||||
cursor: "pointer",
|
||||
background: ATTEMPT_COLORS[JUDGE_STATUS[item.result]?.type ?? "default"],
|
||||
},
|
||||
onClick: (event: MouseEvent) => {
|
||||
event.stopPropagation()
|
||||
openSubmission(item.id)
|
||||
},
|
||||
}),
|
||||
default: () =>
|
||||
`${JUDGE_STATUS[item.result]?.name ?? item.result} · ` +
|
||||
`${parseTime(item.createTime, "MM-DD HH:mm:ss")} · ` +
|
||||
`${item.id.toString().slice(0, 12)}`,
|
||||
},
|
||||
h(
|
||||
NFlex,
|
||||
{ size: 4, wrap: true, style: "flex: 1; min-width: 0" },
|
||||
() =>
|
||||
group.items.map((item) =>
|
||||
h(
|
||||
NTooltip,
|
||||
{ delay: 200 },
|
||||
{
|
||||
trigger: () =>
|
||||
h("button", {
|
||||
// 内联样式而不是 class:这些方块是 h() 出来、挂在 NDataTable 的
|
||||
// 展开槽里渲染的,<style scoped> 能不能盖到它并不确定
|
||||
style: {
|
||||
width: "14px",
|
||||
height: "14px",
|
||||
padding: "0",
|
||||
border: "none",
|
||||
borderRadius: "3px",
|
||||
cursor: "pointer",
|
||||
background:
|
||||
ATTEMPT_COLORS[
|
||||
JUDGE_STATUS[item.result]?.type ?? "default"
|
||||
],
|
||||
},
|
||||
onClick: (event: MouseEvent) => {
|
||||
event.stopPropagation()
|
||||
openSubmission(item.id)
|
||||
},
|
||||
}),
|
||||
default: () =>
|
||||
`${JUDGE_STATUS[item.result]?.name ?? item.result} · ` +
|
||||
`${parseTime(item.createTime, "MM-DD HH:mm:ss")} · ` +
|
||||
`${item.id.toString().slice(0, 12)}`,
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
]),
|
||||
),
|
||||
@@ -358,7 +379,8 @@ const columns: DataTableColumn<SubmissionStatisticsUser>[] = [
|
||||
? h(
|
||||
NText,
|
||||
{ depth: 3 },
|
||||
() => `只显示最近 ${loaded.items.length} 条,上面「提交数」才是总数`,
|
||||
() =>
|
||||
`只显示最近 ${loaded.items.length} 条,上面「提交数」才是总数`,
|
||||
)
|
||||
: null,
|
||||
])
|
||||
@@ -372,7 +394,11 @@ const columns: DataTableColumn<SubmissionStatisticsUser>[] = [
|
||||
render: (row) =>
|
||||
h(
|
||||
NTag,
|
||||
{ size: "small", type: row.done ? "success" : "default", bordered: false },
|
||||
{
|
||||
size: "small",
|
||||
type: row.done ? "success" : "default",
|
||||
bordered: false,
|
||||
},
|
||||
() => (row.done ? "已完成" : "未完成"),
|
||||
),
|
||||
},
|
||||
@@ -693,7 +719,9 @@ const completionChartOptions = {
|
||||
const subOptions = computed<Duration>(
|
||||
// 认不出来(含 all)就退回列表第一档,和原来 `?? options[0]` 一致;
|
||||
// all 实际不会走到这里,handleStatistics 先分支掉了
|
||||
() => durationFromValue(query.duration) ?? durationFromValue(PANEL_DURATION_OPTIONS[0].value)!,
|
||||
() =>
|
||||
durationFromValue(query.duration) ??
|
||||
durationFromValue(PANEL_DURATION_OPTIONS[0].value)!,
|
||||
)
|
||||
|
||||
function goSubmissions() {
|
||||
|
||||
@@ -84,7 +84,8 @@ const handleEditorReady = (payload: EditorReadyPayload) => {
|
||||
watch(
|
||||
() => collabStore.room,
|
||||
(room) => {
|
||||
if (room && !collabStore.isTeacher && editorView.value) bind(editorView.value)
|
||||
if (room && !collabStore.isTeacher && editorView.value)
|
||||
bind(editorView.value)
|
||||
else stop()
|
||||
},
|
||||
)
|
||||
|
||||
@@ -47,15 +47,21 @@ export function useCollabDoc() {
|
||||
if (doc) stop()
|
||||
const myGeneration = ++generation
|
||||
|
||||
const [Y, awarenessProtocol, syncProtocol, encoding, decoding, { yCollab }] =
|
||||
await Promise.all([
|
||||
import("yjs"),
|
||||
import("y-protocols/awareness"),
|
||||
import("y-protocols/sync"),
|
||||
import("lib0/encoding"),
|
||||
import("lib0/decoding"),
|
||||
import("y-codemirror.next"),
|
||||
])
|
||||
const [
|
||||
Y,
|
||||
awarenessProtocol,
|
||||
syncProtocol,
|
||||
encoding,
|
||||
decoding,
|
||||
{ yCollab },
|
||||
] = await Promise.all([
|
||||
import("yjs"),
|
||||
import("y-protocols/awareness"),
|
||||
import("y-protocols/sync"),
|
||||
import("lib0/encoding"),
|
||||
import("lib0/decoding"),
|
||||
import("y-codemirror.next"),
|
||||
])
|
||||
|
||||
// 等 chunk 的这段时间里房间关了(或者又开了新的一轮),整个放弃
|
||||
if (myGeneration !== generation) return
|
||||
@@ -106,7 +112,11 @@ export function useCollabDoc() {
|
||||
detachDocUpdate = () => doc?.off("update", onDocUpdate)
|
||||
|
||||
const onAwarenessUpdate = (
|
||||
{ added, updated, removed }: { added: number[]; updated: number[]; removed: number[] },
|
||||
{
|
||||
added,
|
||||
updated,
|
||||
removed,
|
||||
}: { added: number[]; updated: number[]; removed: number[] },
|
||||
origin: any,
|
||||
) => {
|
||||
if (origin === "remote") return
|
||||
|
||||
@@ -64,7 +64,9 @@ export function useHiddenStudents(storageKey: string) {
|
||||
// 把已经到期的清掉再落一次盘,否则这张表只增不减
|
||||
const now = Date.now()
|
||||
const cleaned = Object.fromEntries(
|
||||
Object.entries(hiddenStudents.value).filter(([, expiresAt]) => expiresAt > now),
|
||||
Object.entries(hiddenStudents.value).filter(
|
||||
([, expiresAt]) => expiresAt > now,
|
||||
),
|
||||
)
|
||||
hiddenStudents.value = cleaned
|
||||
save(cleaned)
|
||||
|
||||
@@ -211,7 +211,9 @@ export class BaseWebSocket<T extends WebSocketMessage = WebSocketMessage> {
|
||||
RECONNECT_MAX_DELAY,
|
||||
)
|
||||
const delay = Math.round(base * (0.5 + Math.random() * 0.5))
|
||||
console.log(`[WebSocket] 将在 ${delay}ms 后重连 (第 ${this.reconnectAttempts} 次)`)
|
||||
console.log(
|
||||
`[WebSocket] 将在 ${delay}ms 后重连 (第 ${this.reconnectAttempts} 次)`,
|
||||
)
|
||||
this.reconnectTimer = window.setTimeout(() => {
|
||||
this.reconnectTimer = null
|
||||
this.connect()
|
||||
@@ -516,7 +518,9 @@ export interface SubmissionUpdate extends WebSocketMessage {
|
||||
}
|
||||
|
||||
/** 判题进度。subscribe(submissionId) 认领,断线重连会自动补订阅 */
|
||||
export function useSubmissionWebSocket(handler?: MessageHandler<SubmissionUpdate>) {
|
||||
export function useSubmissionWebSocket(
|
||||
handler?: MessageHandler<SubmissionUpdate>,
|
||||
) {
|
||||
return useChannel<SubmissionUpdate>("/ws/submissions", handler)
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import type { LANGUAGE } from "utils/types"
|
||||
* Java / Golang / JavaScript 没有单独的包,落到 cpp(),是既有行为,不是遗漏。
|
||||
*/
|
||||
export function languageExtension(language: LANGUAGE): Extension {
|
||||
if (language === "SQL") return sql({ dialect: SQLite, upperCaseKeywords: true })
|
||||
if (language === "SQL")
|
||||
return sql({ dialect: SQLite, upperCaseKeywords: true })
|
||||
return ["Python2", "Python3"].includes(language) ? python() : cpp()
|
||||
}
|
||||
|
||||
@@ -60,11 +60,7 @@ const options = computed<MenuOption[]>(() => {
|
||||
},
|
||||
{
|
||||
label: () =>
|
||||
h(
|
||||
RouterLink,
|
||||
{ to: "/admin/ai/reports" },
|
||||
{ default: () => "报告" },
|
||||
),
|
||||
h(RouterLink, { to: "/admin/ai/reports" }, { default: () => "报告" }),
|
||||
key: "admin ai reports",
|
||||
},
|
||||
{
|
||||
@@ -148,11 +144,7 @@ const options = computed<MenuOption[]>(() => {
|
||||
},
|
||||
{
|
||||
label: () =>
|
||||
h(
|
||||
RouterLink,
|
||||
{ to: "/admin/ai/reports" },
|
||||
{ default: () => "报告" },
|
||||
),
|
||||
h(RouterLink, { to: "/admin/ai/reports" }, { default: () => "报告" }),
|
||||
key: "admin ai reports",
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user