From cb7743367a91aa1074cedccd08eef34030779772 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Tue, 26 May 2026 23:10:15 -0600 Subject: [PATCH] remove contest type --- src/admin/contest/detail.vue | 4 - .../problem/components/AstRulesEditor.vue | 189 +++++++++++++----- src/admin/problem/list.vue | 18 +- src/oj/api.ts | 2 +- src/oj/contest/pages/rank.vue | 2 - src/oj/problem/components/ProblemContent.vue | 48 +++-- .../problem/components/SubmissionResult.vue | 18 +- src/oj/problem/components/SubmitCode.vue | 11 +- src/oj/problem/detail.vue | 6 +- src/utils/functions.ts | 10 +- src/utils/types.ts | 27 ++- 11 files changed, 246 insertions(+), 89 deletions(-) diff --git a/src/admin/contest/detail.vue b/src/admin/contest/detail.vue index d53385a..0cf3b91 100644 --- a/src/admin/contest/detail.vue +++ b/src/admin/contest/detail.vue @@ -56,9 +56,7 @@ const contest = reactive({ tag: "练习", start_time: "", end_time: "", - rule_type: "ACM", password: "", - real_time_rank: true, visible: false, allowed_ip_ranges: [], }) @@ -79,9 +77,7 @@ async function getContestDetail() { contest.tag = data.tag contest.start_time = data.start_time contest.end_time = data.end_time - contest.rule_type = "ACM" contest.password = data.password - contest.real_time_rank = true contest.visible = data.visible contest.allowed_ip_ranges = [] diff --git a/src/admin/problem/components/AstRulesEditor.vue b/src/admin/problem/components/AstRulesEditor.vue index 7aa4152..3c5aedf 100644 --- a/src/admin/problem/components/AstRulesEditor.vue +++ b/src/admin/problem/components/AstRulesEditor.vue @@ -24,23 +24,41 @@ const emit = defineEmits<{ const activeTab = ref(props.languages[0] || "Python3") const ENGINE_OPTIONS: SelectOption[] = [ - { label: "节点检查", type: "group", key: "node_group", children: [ - { label: "必须存在", value: "must_exist_node" }, - { label: "不能存在", value: "must_not_exist_node" }, - { label: "出现次数", value: "count_node" }, - ]}, - { label: "函数调用", type: "group", key: "func_group", children: [ - { label: "必须调用函数", value: "must_call_function" }, - { label: "不能调用函数", value: "must_not_call_function" }, - { label: "函数调用次数", value: "count_function_call" }, - ]}, - { label: "方法调用", type: "group", key: "method_group", children: [ - { label: "必须调用方法", value: "must_call_method" }, - { label: "不能调用方法", value: "must_not_call_method" }, - ]}, - { label: "运算符", type: "group", key: "op_group", children: [ - { label: "必须使用运算符", value: "must_use_operator" }, - ]}, + { + label: "节点检查", + type: "group", + key: "node_group", + children: [ + { label: "必须存在", value: "must_exist_node" }, + { label: "不能存在", value: "must_not_exist_node" }, + { label: "出现次数", value: "count_node" }, + ], + }, + { + label: "函数调用", + type: "group", + key: "func_group", + children: [ + { label: "必须调用函数", value: "must_call_function" }, + { label: "不能调用函数", value: "must_not_call_function" }, + { label: "函数调用次数", value: "count_function_call" }, + ], + }, + { + label: "方法调用", + type: "group", + key: "method_group", + children: [ + { label: "必须调用方法", value: "must_call_method" }, + { label: "不能调用方法", value: "must_not_call_method" }, + ], + }, + { + label: "运算符", + type: "group", + key: "op_group", + children: [{ label: "必须使用运算符", value: "must_use_operator" }], + }, ] const NODE_TARGET_OPTIONS: SelectOption[] = [ @@ -83,16 +101,30 @@ const OPERATOR_TARGET_OPTIONS: SelectOption[] = [ ] const NODE_ENGINES = ["must_exist_node", "must_not_exist_node", "count_node"] -const FUNCTION_ENGINES = ["must_call_function", "must_not_call_function", "count_function_call"] +const FUNCTION_ENGINES = [ + "must_call_function", + "must_not_call_function", + "count_function_call", +] const METHOD_ENGINES = ["must_call_method", "must_not_call_method"] const OPERATOR_ENGINES = ["must_use_operator"] const COUNT_ENGINES = ["count_node", "count_function_call"] -function isNodeEngine(engine: string) { return NODE_ENGINES.includes(engine) } -function isFunctionEngine(engine: string) { return FUNCTION_ENGINES.includes(engine) } -function isMethodEngine(engine: string) { return METHOD_ENGINES.includes(engine) } -function isOperatorEngine(engine: string) { return OPERATOR_ENGINES.includes(engine) } -function isCountEngine(engine: string) { return COUNT_ENGINES.includes(engine) } +function isNodeEngine(engine: string) { + return NODE_ENGINES.includes(engine) +} +function isFunctionEngine(engine: string) { + return FUNCTION_ENGINES.includes(engine) +} +function isMethodEngine(engine: string) { + return METHOD_ENGINES.includes(engine) +} +function isOperatorEngine(engine: string) { + return OPERATOR_ENGINES.includes(engine) +} +function isCountEngine(engine: string) { + return COUNT_ENGINES.includes(engine) +} const COUNT_MODE_OPTIONS: SelectOption[] = [ { label: "精确", value: "exact" }, @@ -126,9 +158,15 @@ function updateExactCount(lang: string, index: number, v: number | null) { updateRules(lang, rules) } -function needsTargetDropdown(engine: string) { return isNodeEngine(engine) } -function needsTargetInput(engine: string) { return isFunctionEngine(engine) || isMethodEngine(engine) } -function needsOperatorDropdown(engine: string) { return isOperatorEngine(engine) } +function needsTargetDropdown(engine: string) { + return isNodeEngine(engine) +} +function needsTargetInput(engine: string) { + return isFunctionEngine(engine) || isMethodEngine(engine) +} +function needsOperatorDropdown(engine: string) { + return isOperatorEngine(engine) +} function getRulesForLang(lang: string): AstRule[] { if (!props.modelValue) return [] @@ -149,13 +187,19 @@ function getTargetLabel(engine: string, target: string): string | undefined { if (isNodeEngine(engine)) return (NODE_TARGET_OPTIONS.find((o) => o.value === target) as any)?.label if (isOperatorEngine(engine)) - return (OPERATOR_TARGET_OPTIONS.find((o) => o.value === target) as any)?.label + return (OPERATOR_TARGET_OPTIONS.find((o) => o.value === target) as any) + ?.label return undefined } function addRule(lang: string) { const rules = [...getRulesForLang(lang)] - rules.push({ engine: "must_exist_node", target: "for_loop", label: "for 循环", message: "" }) + rules.push({ + engine: "must_exist_node", + target: "for_loop", + label: "for 循环", + message: "", + }) updateRules(lang, rules) } @@ -171,9 +215,16 @@ function updateRule(lang: string, index: number, field: string, value: any) { if (field === "engine") { rule.engine = value - if (isNodeEngine(value)) { rule.target = "for_loop"; rule.label = "for 循环" } - else if (isOperatorEngine(value)) { rule.target = "+"; rule.label = "+" } - else { rule.target = ""; delete rule.label } + if (isNodeEngine(value)) { + rule.target = "for_loop" + rule.label = "for 循环" + } else if (isOperatorEngine(value)) { + rule.target = "+" + rule.label = "+" + } else { + rule.target = "" + delete rule.label + } delete rule.min delete rule.max delete rule.exact @@ -196,25 +247,39 @@ function updateRule(lang: string, index: number, field: string, value: any) { updateRules(lang, rules) } -watch(() => props.languages, (langs) => { - if (langs.length && !langs.includes(activeTab.value as LANGUAGE)) { - activeTab.value = langs[0] - } -}) +watch( + () => props.languages, + (langs) => { + if (langs.length && !langs.includes(activeTab.value as LANGUAGE)) { + activeTab.value = langs[0] + } + }, +)