From 87d2b828a1d7ebacfc0037927db88cc75f613926 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Sun, 12 Oct 2025 15:57:59 +0800 Subject: [PATCH] update --- src/admin/setting/config.vue | 4 +- src/oj/problem/components/Form.vue | 45 ++++++++++++------- .../components/{Submit.vue => SubmitCode.vue} | 0 src/oj/problem/components/SubmitFlowchart.vue | 20 +++++++++ .../components/ButtonWithSearch.vue | 4 +- src/shared/composables/configUpdate.ts | 2 +- src/shared/composables/maxkb.ts | 2 +- src/utils/constants.ts | 6 ++- src/utils/types.ts | 1 + 9 files changed, 63 insertions(+), 21 deletions(-) rename src/oj/problem/components/{Submit.vue => SubmitCode.vue} (100%) create mode 100644 src/oj/problem/components/SubmitFlowchart.vue diff --git a/src/admin/setting/config.vue b/src/admin/setting/config.vue index 84a0def..962bc57 100644 --- a/src/admin/setting/config.vue +++ b/src/admin/setting/config.vue @@ -30,10 +30,10 @@ watch( (isAuthed) => { if (!isAuthed) { // 如果用户未登录,禁用WebSocket功能 - console.warn('用户未登录,WebSocket配置更新功能已禁用') + console.warn("用户未登录,WebSocket配置更新功能已禁用") } }, - { immediate: true } + { immediate: true }, ) const testcaseColumns: DataTableColumn[] = [ diff --git a/src/oj/problem/components/Form.vue b/src/oj/problem/components/Form.vue index bda8b26..865f897 100644 --- a/src/oj/problem/components/Form.vue +++ b/src/oj/problem/components/Form.vue @@ -5,16 +5,25 @@ import { useCodeStore } from "oj/store/code" import { useProblemStore } from "oj/store/problem" import { injectSyncStatus } from "oj/composables/syncStatus" import { SYNC_MESSAGES } from "shared/composables/sync" -import { ICON_SET, LANGUAGE_SHOW_VALUE, SOURCES, STORAGE_KEY } from "utils/constants" +import { + ICON_SET, + LANGUAGE_SHOW_VALUE, + SOURCES, + STORAGE_KEY, +} from "utils/constants" import { useBreakpoints } from "shared/composables/breakpoints" import { useUserStore } from "shared/store/user" import storage from "utils/storage" import { LANGUAGE } from "utils/types" -import Submit from "./Submit.vue" import StatisticsPanel from "shared/components/StatisticsPanel.vue" import IconButton from "shared/components/IconButton.vue" import { Icon } from "@iconify/vue" import { NFlex } from "naive-ui" +import SubmitCode from "./SubmitCode.vue" + +const SubmitFlowchart = defineAsyncComponent( + () => import("./SubmitFlowchart.vue"), +) interface Props { storageKey: string @@ -59,25 +68,23 @@ const menu = computed(() => [ { label: "重置代码", key: "reset" }, ]) -const flowchartAndLanguages = computed(() => [ - ...(problem.value!.allow_flowchart ? ["Flowchart"] : []), - ...problem.value!.languages, -]) - -const Options = { - Flowchart: "流程图", - ...LANGUAGE_SHOW_VALUE, -} +const flowchartAndLanguages = computed( + () => + [ + ...(problem.value!.allow_flowchart ? ["Flowchart"] : []), + ...problem.value!.languages, + ] as LANGUAGE[], +) const languageOptions: DropdownOption[] = flowchartAndLanguages.value.map( (it) => ({ label: () => - h(NFlex, { align: "center" }, [ + h(NFlex, { align: "center" }, () => [ h(Icon, { - icon: ICON_SET[it as keyof typeof ICON_SET], + icon: ICON_SET[it], width: 16, }), - Options[it as keyof typeof Options], + LANGUAGE_SHOW_VALUE[it], ]), value: it, }), @@ -137,6 +144,12 @@ defineExpose({ syncEnabled.value = false }, }) + +onMounted(() => { + if (!problem.value!.languages.includes(codeStore.code.language)) { + codeStore.code.language = "Python3" + } +})