From b3091db7b2ea2aee565da6da151531fa7fe7a100 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Sun, 21 Sep 2025 19:33:00 +0800 Subject: [PATCH] filter by language --- src/components.d.ts | 19 ------------------- src/oj/submission/list.vue | 26 ++++++++++++++++++++++---- src/utils/types.ts | 1 + 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/components.d.ts b/src/components.d.ts index b29edcf..1c557da 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -9,51 +9,32 @@ export {} declare module 'vue' { export interface GlobalComponents { NAlert: typeof import('naive-ui')['NAlert'] - NAvatar: typeof import('naive-ui')['NAvatar'] NButton: typeof import('naive-ui')['NButton'] NCard: typeof import('naive-ui')['NCard'] NCode: typeof import('naive-ui')['NCode'] NCollapseTransition: typeof import('naive-ui')['NCollapseTransition'] NConfigProvider: typeof import('naive-ui')['NConfigProvider'] NDataTable: typeof import('naive-ui')['NDataTable'] - NDescriptions: typeof import('naive-ui')['NDescriptions'] - NDescriptionsItem: typeof import('naive-ui')['NDescriptionsItem'] NDropdown: typeof import('naive-ui')['NDropdown'] - NDynamicTags: typeof import('naive-ui')['NDynamicTags'] - NEmpty: typeof import('naive-ui')['NEmpty'] NFlex: typeof import('naive-ui')['NFlex'] NForm: typeof import('naive-ui')['NForm'] NFormItem: typeof import('naive-ui')['NFormItem'] - NFormItemGi: typeof import('naive-ui')['NFormItemGi'] - NGi: typeof import('naive-ui')['NGi'] NGradientText: typeof import('naive-ui')['NGradientText'] - NGrid: typeof import('naive-ui')['NGrid'] NH1: typeof import('naive-ui')['NH1'] - NH2: typeof import('naive-ui')['NH2'] - NH4: typeof import('naive-ui')['NH4'] NIcon: typeof import('naive-ui')['NIcon'] NInput: typeof import('naive-ui')['NInput'] NLayout: typeof import('naive-ui')['NLayout'] NLayoutContent: typeof import('naive-ui')['NLayoutContent'] NLayoutHeader: typeof import('naive-ui')['NLayoutHeader'] - NLayoutSider: typeof import('naive-ui')['NLayoutSider'] NMenu: typeof import('naive-ui')['NMenu'] NMessageProvider: typeof import('naive-ui')['NMessageProvider'] NModal: typeof import('naive-ui')['NModal'] - NNumberAnimation: typeof import('naive-ui')['NNumberAnimation'] NPagination: typeof import('naive-ui')['NPagination'] - NPopconfirm: typeof import('naive-ui')['NPopconfirm'] - NPopover: typeof import('naive-ui')['NPopover'] - NRate: typeof import('naive-ui')['NRate'] - NScrollbar: typeof import('naive-ui')['NScrollbar'] NSelect: typeof import('naive-ui')['NSelect'] NSpace: typeof import('naive-ui')['NSpace'] NSwitch: typeof import('naive-ui')['NSwitch'] - NTabPane: typeof import('naive-ui')['NTabPane'] - NTabs: typeof import('naive-ui')['NTabs'] NTag: typeof import('naive-ui')['NTag'] NText: typeof import('naive-ui')['NText'] - NTooltip: typeof import('naive-ui')['NTooltip'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] } diff --git a/src/oj/submission/list.vue b/src/oj/submission/list.vue index 9d7e9c0..af36963 100644 --- a/src/oj/submission/list.vue +++ b/src/oj/submission/list.vue @@ -2,7 +2,7 @@ import { NButton, NH2, NText } from "naive-ui" import { adminRejudge, getSubmissions, getTodaySubmissionCount } from "oj/api" import { filterEmptyValue, parseTime } from "utils/functions" -import { Submission } from "utils/types" +import { LANGUAGE, Submission } from "utils/types" import Pagination from "~/shared/components/Pagination.vue" import SubmissionResultTag from "~/shared/components/SubmissionResultTag.vue" import { isDesktop } from "~/shared/composables/breakpoints" @@ -21,6 +21,7 @@ interface Query { page: number myself: boolean problem: string + language: LANGUAGE | "" } const route = useRoute() @@ -38,12 +39,13 @@ const query = reactive({ username: route.query.username ?? "", myself: route.query.myself === "1", problem: route.query.problem ?? "", + language: route.query.language ?? "", }) const submissionID = ref("") const [statisticPanel, toggleStatisticPanel] = useToggle(false) const [codePanel, toggleCodePanel] = useToggle(false) -const options: SelectOption[] = [ +const resultOptions: SelectOption[] = [ { label: "全部", value: "" }, { label: "答案正确", value: "0" }, { label: "答案错误", value: "-1" }, @@ -51,6 +53,12 @@ const options: SelectOption[] = [ { label: "运行时错误", value: "4" }, ] +const languageOptions: SelectOption[] = [ + { label: "全部", value: "" }, + { label: "Python", value: "Python3" }, + { label: "C语言", value: "C" }, + { label: "C++", value: "C++" }, +] async function listSubmissions() { query.result = route.query.result ?? "" query.page = parseInt(route.query.page) || 1 @@ -58,6 +66,7 @@ async function listSubmissions() { query.username = route.query.username ?? "" query.myself = route.query.myself === "1" query.problem = route.query.problem ?? "" + query.language = route.query.language ?? "" if (query.page < 1) query.page = 1 const offset = query.limit * (query.page - 1) @@ -67,6 +76,7 @@ async function listSubmissions() { offset, problem_id: route.query.problem ?? "", contest_id: route.params.contestID ?? "", + language: query.language, }) submissions.value = res.data.results total.value = res.data.total @@ -105,6 +115,7 @@ function clear() { query.myself = false query.result = "" query.problem = "" + query.language = "" } async function rejudge(submissionID: string) { @@ -135,7 +146,7 @@ function showCodePanel(id: string) { watch(() => query.page, routerPush) watch( - () => [query.limit, query.myself, query.result], + () => [query.limit, query.myself, query.result, query.language], () => { query.page = 1 routerPush() @@ -253,7 +264,14 @@ const columns = computed(() => { + + + diff --git a/src/utils/types.ts b/src/utils/types.ts index 0864d9c..8dca87b 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -229,6 +229,7 @@ export interface SubmissionListPayload { username?: string contest_id?: string problem_id?: string + language?: LANGUAGE page: number limit: number offset: number