diff --git a/src/admin/api.ts b/src/admin/api.ts index f9bfb73..c07ced5 100644 --- a/src/admin/api.ts +++ b/src/admin/api.ts @@ -25,8 +25,8 @@ export async function getProblemList( offset = 0, limit = 10, keyword: string, + author?: string, contestID?: string, - ruleType?: "ACM" | "OI", ) { const endpoint = !!contestID ? "admin/contest/problem" : "admin/problem" const res = await http.get(endpoint, { @@ -35,8 +35,8 @@ export async function getProblemList( offset, limit, keyword, + author, contest_id: contestID, - rule_type: ruleType, }, }) return { diff --git a/src/admin/problem/list.vue b/src/admin/problem/list.vue index 336deb2..e70fe06 100644 --- a/src/admin/problem/list.vue +++ b/src/admin/problem/list.vue @@ -8,6 +8,7 @@ import { getProblemList, toggleProblemVisible } from "../api" import Actions from "./components/Actions.vue" import Modal from "./components/Modal.vue" import { useRouteQuery } from "@vueuse/router" +import AuthorSelect from "~/shared/components/AuthorSelect.vue" interface Props { contestID?: string @@ -35,11 +36,13 @@ const problems = ref([]) interface ProblemQuery { keyword: string + author: string } // 使用分页 composable const { query, clearQuery } = usePagination({ keyword: useRouteQuery("keyword", "").value, + author: useRouteQuery("author", "").value, }) const columns: DataTableColumn[] = [ @@ -77,7 +80,6 @@ const columns: DataTableColumn[] = [ }, ] - async function listProblems() { if (query.page < 1) query.page = 1 const offset = (query.page - 1) * query.limit @@ -85,6 +87,7 @@ async function listProblems() { offset, query.limit, query.keyword, + query.author, props.contestID, ) total.value = res.total @@ -116,17 +119,13 @@ async function selectProblems() { onMounted(listProblems) // 监听搜索关键词变化(防抖) -watchDebounced( - () => query.keyword, - listProblems, - { debounce: 500, maxWait: 1000 }, -) +watchDebounced(() => query.keyword, listProblems, { + debounce: 500, + maxWait: 1000, +}) // 监听其他查询条件变化 -watch( - () => [query.page, query.limit], - listProblems, -) +watch(() => [query.page, query.limit, query.author], listProblems)