From 43e0376fba32cfd5ab00ad987a6a00a4bdd2ff09 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Tue, 14 Oct 2025 21:30:39 +0800 Subject: [PATCH] add sort --- src/oj/problem/list.vue | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/oj/problem/list.vue b/src/oj/problem/list.vue index e5fa38a..b8a96f8 100644 --- a/src/oj/problem/list.vue +++ b/src/oj/problem/list.vue @@ -27,6 +27,7 @@ interface ProblemQuery { difficulty: string tag: string author: string + sort: string } const difficultyOptions = [ @@ -36,6 +37,15 @@ const difficultyOptions = [ { label: "困难", value: "High" }, ] +const sortOptions = [ + { label: "最新创建", value: "" }, + { label: "最早创建", value: "create_time" }, + { label: "最多提交", value: "-submission_number" }, + { label: "最少提交", value: "submission_number" }, + { label: "最多通过", value: "-accepted_number" }, + { label: "最少通过", value: "accepted_number" }, +] + const router = useRouter() const userStore = useUserStore() @@ -53,6 +63,7 @@ const { query, clearQuery } = usePagination({ difficulty: useRouteQuery("difficulty", "").value, tag: useRouteQuery("tag", "").value, author: useRouteQuery("author", "").value, + sort: useRouteQuery("sort", "").value, }) async function listProblems() { @@ -63,6 +74,7 @@ async function listProblems() { tag: query.tag, difficulty: query.difficulty, author: query.author, + sort: query.sort, }) total.value = res.total problems.value = res.results @@ -101,7 +113,14 @@ watchDebounced(() => query.keyword, listProblems, { // 监听其他查询条件变化 watch( - () => [query.tag, query.difficulty, query.limit, query.page, query.author], + () => [ + query.tag, + query.difficulty, + query.limit, + query.page, + query.author, + query.sort, + ], listProblems, ) @@ -215,6 +234,13 @@ function rowProps(row: ProblemFiltered) { + + + + + 重置