diff --git a/apps/api/src/routes/problem.ts b/apps/api/src/routes/problem.ts index 974477a..5425175 100644 --- a/apps/api/src/routes/problem.ts +++ b/apps/api/src/routes/problem.ts @@ -169,10 +169,10 @@ problemRoutes.get("/problems", optionalAuth, async (c) => { filters.push(notInArray(schema.problem.id, [...states.solved])) const where = and(...filters) - // 默认:选了知识点按题号(同一系列的题挨在一起),全部题目按最新创建。 - // 旧的排序值(最多提交、画流程图……)落到默认 —— 类型已经拆成了单独的筛选 + // 默认按最新创建(选了知识点也一样)。旧的排序值(最多提交、画流程图……)落到默认 —— + // 类型已经拆成了单独的筛选 const sort = problemListSortSchema.safeParse(c.req.query("sort") ?? "").data ?? "" - const effective = sort || (tag ? "id" : "new") + const effective = sort || "new" const allCounts = effective === "popular" ? await problemUserCounts() : null const popularity = allCounts ? sql`case ${schema.problem.id} ${sql.join( diff --git a/apps/web/src/oj/problem/list.vue b/apps/web/src/oj/problem/list.vue index ca5fe89..3863f15 100644 --- a/apps/web/src/oj/problem/list.vue +++ b/apps/web/src/oj/problem/list.vue @@ -179,15 +179,12 @@ const countText = computed(() => { return { kind: "total" as const, n: total.value } }) -// ---- 排序:默认随知识点走(选了按题号,全部按最新创建),下拉里显示的是实际生效的那个 ---- -const sortOptions = computed(() => { - const byId = !!query.tag - return [ - { label: byId ? "按题号" : "最新创建", value: "" }, - { label: byId ? "最新创建" : "按题号", value: byId ? "new" : "id" }, - { label: "最多人做对", value: "popular" }, - ] -}) +// ---- 排序:默认按最新创建(选了知识点也一样) ---- +const sortOptions = [ + { label: "最新创建", value: "" }, + { label: "按题号", value: "id" }, + { label: "最多人做对", value: "popular" }, +] // ---- 出题者 ---- const authorOptions = ref<{ label: string; value: string }[]>([]) diff --git a/packages/contract/src/problem.ts b/packages/contract/src/problem.ts index b07ad38..34af3f0 100644 --- a/packages/contract/src/problem.ts +++ b/packages/contract/src/problem.ts @@ -439,7 +439,7 @@ export const problemListSchema = paginatedSchema(problemListItemSchema) /** 题目列表「全部类型」下拉:有参考图 / 画流程图 / 语法要求 */ export const problemTypeFilterSchema = z.enum(["reference", "flowchart", "ast"]) -/** 题目列表的排序。空串是默认:选了知识点按题号,全部题目按最新创建 */ +/** 题目列表的排序。空串是默认:按最新创建 */ export const problemListSortSchema = z.enum(["", "id", "new", "popular"]) /**