update
Some checks failed
Deploy / deploy (push) Has been cancelled

This commit is contained in:
2025-10-12 15:57:59 +08:00
parent 4335ffb1e1
commit 87d2b828a1
9 changed files with 63 additions and 21 deletions

View File

@@ -30,10 +30,10 @@ watch(
(isAuthed) => { (isAuthed) => {
if (!isAuthed) { if (!isAuthed) {
// 如果用户未登录禁用WebSocket功能 // 如果用户未登录禁用WebSocket功能
console.warn('用户未登录WebSocket配置更新功能已禁用') console.warn("用户未登录WebSocket配置更新功能已禁用")
} }
}, },
{ immediate: true } { immediate: true },
) )
const testcaseColumns: DataTableColumn<Testcase>[] = [ const testcaseColumns: DataTableColumn<Testcase>[] = [

View File

@@ -5,16 +5,25 @@ import { useCodeStore } from "oj/store/code"
import { useProblemStore } from "oj/store/problem" import { useProblemStore } from "oj/store/problem"
import { injectSyncStatus } from "oj/composables/syncStatus" import { injectSyncStatus } from "oj/composables/syncStatus"
import { SYNC_MESSAGES } from "shared/composables/sync" 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 { useBreakpoints } from "shared/composables/breakpoints"
import { useUserStore } from "shared/store/user" import { useUserStore } from "shared/store/user"
import storage from "utils/storage" import storage from "utils/storage"
import { LANGUAGE } from "utils/types" import { LANGUAGE } from "utils/types"
import Submit from "./Submit.vue"
import StatisticsPanel from "shared/components/StatisticsPanel.vue" import StatisticsPanel from "shared/components/StatisticsPanel.vue"
import IconButton from "shared/components/IconButton.vue" import IconButton from "shared/components/IconButton.vue"
import { Icon } from "@iconify/vue" import { Icon } from "@iconify/vue"
import { NFlex } from "naive-ui" import { NFlex } from "naive-ui"
import SubmitCode from "./SubmitCode.vue"
const SubmitFlowchart = defineAsyncComponent(
() => import("./SubmitFlowchart.vue"),
)
interface Props { interface Props {
storageKey: string storageKey: string
@@ -59,25 +68,23 @@ const menu = computed<DropdownOption[]>(() => [
{ label: "重置代码", key: "reset" }, { label: "重置代码", key: "reset" },
]) ])
const flowchartAndLanguages = computed(() => [ const flowchartAndLanguages = computed(
...(problem.value!.allow_flowchart ? ["Flowchart"] : []), () =>
...problem.value!.languages, [
]) ...(problem.value!.allow_flowchart ? ["Flowchart"] : []),
...problem.value!.languages,
const Options = { ] as LANGUAGE[],
Flowchart: "流程图", )
...LANGUAGE_SHOW_VALUE,
}
const languageOptions: DropdownOption[] = flowchartAndLanguages.value.map( const languageOptions: DropdownOption[] = flowchartAndLanguages.value.map(
(it) => ({ (it) => ({
label: () => label: () =>
h(NFlex, { align: "center" }, [ h(NFlex, { align: "center" }, () => [
h(Icon, { h(Icon, {
icon: ICON_SET[it as keyof typeof ICON_SET], icon: ICON_SET[it],
width: 16, width: 16,
}), }),
Options[it as keyof typeof Options], LANGUAGE_SHOW_VALUE[it],
]), ]),
value: it, value: it,
}), }),
@@ -137,6 +144,12 @@ defineExpose({
syncEnabled.value = false syncEnabled.value = false
}, },
}) })
onMounted(() => {
if (!problem.value!.languages.includes(codeStore.code.language)) {
codeStore.code.language = "Python3"
}
})
</script> </script>
<template> <template>
@@ -149,7 +162,9 @@ defineExpose({
@update:value="changeLanguage" @update:value="changeLanguage"
/> />
<Submit /> <SubmitFlowchart v-if="codeStore.code.language === 'Flowchart'" />
<SubmitCode v-else />
<n-button <n-button
v-if="!userStore.isSuperAdmin && userStore.showSubmissions" v-if="!userStore.isSuperAdmin && userStore.showSubmissions"

View File

@@ -0,0 +1,20 @@
<script lang="ts" setup>
import { useBreakpoints } from "shared/composables/breakpoints"
const { isDesktop } = useBreakpoints()
const message = useMessage()
const submit = () => {
message.warning("暂未实现")
}
</script>
<template>
<n-button
:size="isDesktop ? 'medium' : 'small'"
type="primary"
@click="submit"
>
提交流程图
</n-button>
</template>

View File

@@ -23,7 +23,9 @@ function filterClass() {
</script> </script>
<template> <template>
<n-flex align="center"> <n-flex align="center">
<n-button text type="info" @click="$emit('click')"><slot></slot></n-button> <n-button text type="info" @click="$emit('click')">
<slot></slot>
</n-button>
<n-tooltip> <n-tooltip>
<template #trigger> <template #trigger>
<n-button text @click="$emit('search')"> <n-button text @click="$emit('search')">

View File

@@ -31,7 +31,7 @@ export function useConfigUpdate() {
disconnect() disconnect()
} }
}, },
{ immediate: true } { immediate: true },
) )
return { return {

View File

@@ -34,7 +34,7 @@ export function useMaxKB() {
disconnect() disconnect()
} }
}, },
{ immediate: true } { immediate: true },
) )
const loadMaxKBScript = () => { const loadMaxKBScript = () => {

View File

@@ -154,6 +154,7 @@ export const SOURCES = {
Python2: "", Python2: "",
JavaScript: "", JavaScript: "",
Golang: "", Golang: "",
Flowchart: "",
} as const } as const
export const LANGUAGE_ID = { export const LANGUAGE_ID = {
@@ -164,6 +165,7 @@ export const LANGUAGE_ID = {
Python2: 0, Python2: 0,
JavaScript: 0, JavaScript: 0,
Golang: 0, Golang: 0,
Flowchart: 0,
} as const } as const
export const LANGUAGE_FORMAT_VALUE = { export const LANGUAGE_FORMAT_VALUE = {
@@ -174,9 +176,11 @@ export const LANGUAGE_FORMAT_VALUE = {
Python3: "python", Python3: "python",
JavaScript: "javascript", JavaScript: "javascript",
Golang: "go", Golang: "go",
Flowchart: "flowchart",
} as const } as const
export const LANGUAGE_SHOW_VALUE = { export const LANGUAGE_SHOW_VALUE = {
Flowchart: "流程图",
C: "C语言", C: "C语言",
"C++": "C++", "C++": "C++",
Java: "Java", Java: "Java",
@@ -187,7 +191,7 @@ export const LANGUAGE_SHOW_VALUE = {
} as const } as const
export const ICON_SET = { export const ICON_SET = {
Flowchart: "material-symbols:flowchart", Flowchart: "streamline-freehand-color:programming-flowchart",
Python2: "devicon:python", Python2: "devicon:python",
Python3: "devicon:python", Python3: "devicon:python",
C: "devicon:c", C: "devicon:c",

View File

@@ -59,6 +59,7 @@ export type LANGUAGE =
| "Java" | "Java"
| "JavaScript" | "JavaScript"
| "Golang" | "Golang"
| "Flowchart"
export type LANGUAGE_SHOW_LABEL = export type LANGUAGE_SHOW_LABEL =
(typeof LANGUAGE_SHOW_VALUE)[keyof typeof LANGUAGE_SHOW_VALUE] (typeof LANGUAGE_SHOW_VALUE)[keyof typeof LANGUAGE_SHOW_VALUE]