fix(题目列表): 选了知识点后题目改成按题号排,和平时看惯的「最新的在前」不一样——默认一律按最新创建

排序下拉固定三项:最新创建(默认)/ 按题号 / 最多人做对。

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
xuyueandClaude Opus 5.5 committed 2026-10-09 12:57:14 +08:00
1 parent 74af88046e
commit 97426f0895
3 files changed
+10 -13

No files matched your search

+3 -3
View File
@@ -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(
+6 -9
View File
@@ -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 }[]>([])
+1 -1
View File
@@ -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"])
/**