update
Some checks failed
Deploy / deploy (build, debian, 22, /root/OJDeploy/data/clientnext) (push) Has been cancelled
Deploy / deploy (build:staging, school, 8822, /root/OJ/data/dist) (push) Has been cancelled

This commit is contained in:
2026-05-25 07:01:07 -06:00
parent 873b7c875b
commit 8e2fcceb8f
5 changed files with 47 additions and 46 deletions

View File

@@ -1,8 +1,8 @@
<script setup lang="ts"> <script setup lang="ts">
import { usePinnedFlowchartStore } from "shared/store/pinnedFlowchart" import { useMyFlowchartStore } from "shared/store/myFlowchart"
import { useMermaid } from "shared/composables/useMermaid" import { useMermaid } from "shared/composables/useMermaid"
const store = usePinnedFlowchartStore() const store = useMyFlowchartStore()
const { renderError, renderFlowchart } = useMermaid() const { renderError, renderFlowchart } = useMermaid()
const mermaidContainer = useTemplateRef<HTMLElement>("mermaidContainer") const mermaidContainer = useTemplateRef<HTMLElement>("mermaidContainer")

View File

@@ -12,7 +12,7 @@ import {
useFlowchartWebSocket, useFlowchartWebSocket,
type FlowchartEvaluationUpdate, type FlowchartEvaluationUpdate,
} from "shared/composables/websocket" } from "shared/composables/websocket"
import { usePinnedFlowchartStore } from "shared/store/pinnedFlowchart" import { useMyFlowchartStore } from "shared/store/myFlowchart"
// API 和状态管理 // API 和状态管理
import { import {
@@ -52,7 +52,7 @@ const message = useMessage()
const problemStore = useProblemStore() const problemStore = useProblemStore()
const { problem } = toRefs(problemStore) const { problem } = toRefs(problemStore)
const { isDesktop } = useBreakpoints() const { isDesktop } = useBreakpoints()
const pinnedStore = usePinnedFlowchartStore() const myFlowchartStore = useMyFlowchartStore()
const { convertToMermaid } = useMermaidConverter() const { convertToMermaid } = useMermaidConverter()
const { renderError, renderFlowchart } = useMermaid() const { renderError, renderFlowchart } = useMermaid()
@@ -95,7 +95,7 @@ const handleWebSocketMessage = (data: FlowchartEvaluationUpdate) => {
latestRating.value = { score: data.score || 0, grade } latestRating.value = { score: data.score || 0, grade }
message.success(`流程图评分完成!得分: ${data.score}分 (${grade}级)`) message.success(`流程图评分完成!得分: ${data.score}分 (${grade}级)`)
if ((grade === "A" || grade === "S") && lastSubmittedMermaidCode.value) { if ((grade === "A" || grade === "S") && lastSubmittedMermaidCode.value) {
pinnedStore.pin(lastSubmittedMermaidCode.value) myFlowchartStore.show(lastSubmittedMermaidCode.value)
} }
} else if (data.type === "flowchart_evaluation_failed") { } else if (data.type === "flowchart_evaluation_failed") {
loading.value = false loading.value = false
@@ -263,7 +263,7 @@ onMounted(async () => {
if ((grade === "A" || grade === "S") && submissionCount.value > 0) { if ((grade === "A" || grade === "S") && submissionCount.value > 0) {
await getSubmission(submissionCount.value) await getSubmission(submissionCount.value)
if (myMermaidCode.value) { if (myMermaidCode.value) {
pinnedStore.pin(myMermaidCode.value) myFlowchartStore.show(myMermaidCode.value)
} }
} }
}) })

View File

@@ -4,7 +4,7 @@ import { useBreakpoints } from "shared/composables/breakpoints"
import { storeToRefs } from "pinia" import { storeToRefs } from "pinia"
import { useProblemStore } from "oj/store/problem" import { useProblemStore } from "oj/store/problem"
import { useScreenModeStore } from "shared/store/screenMode" import { useScreenModeStore } from "shared/store/screenMode"
import { usePinnedFlowchartStore } from "shared/store/pinnedFlowchart" import { useMyFlowchartStore } from "shared/store/myFlowchart"
const ProblemEditor = defineAsyncComponent( const ProblemEditor = defineAsyncComponent(
() => import("./components/ProblemEditor.vue"), () => import("./components/ProblemEditor.vue"),
@@ -30,8 +30,8 @@ const ProblemComment = defineAsyncComponent(
const ProblemFlowchart = defineAsyncComponent( const ProblemFlowchart = defineAsyncComponent(
() => import("./components/ProblemFlowchart.vue"), () => import("./components/ProblemFlowchart.vue"),
) )
const PinnedFlowchartTab = defineAsyncComponent( const MyFlowchartTab = defineAsyncComponent(
() => import("./components/PinnedFlowchartTab.vue"), () => import("./components/MyFlowchartTab.vue"),
) )
interface Props { interface Props {
@@ -51,7 +51,7 @@ const router = useRouter()
const problemStore = useProblemStore() const problemStore = useProblemStore()
const screenModeStore = useScreenModeStore() const screenModeStore = useScreenModeStore()
const pinnedStore = usePinnedFlowchartStore() const myFlowchartStore = useMyFlowchartStore()
const { problem } = storeToRefs(problemStore) const { problem } = storeToRefs(problemStore)
const { shouldShowProblem } = storeToRefs(screenModeStore) const { shouldShowProblem } = storeToRefs(screenModeStore)
@@ -62,6 +62,7 @@ const tabOptions = computed(() => {
if (problem.value?.show_flowchart) { if (problem.value?.show_flowchart) {
options.push("flowchart") options.push("flowchart")
} }
if (isMobile.value) { if (isMobile.value) {
options.push("editor") options.push("editor")
} }
@@ -69,8 +70,8 @@ const tabOptions = computed(() => {
if (!props.contestID) { if (!props.contestID) {
options.push("comment") options.push("comment")
} }
if (pinnedStore.isPinned) { if (myFlowchartStore.showing) {
options.push("pinned") options.push("my-flowchart")
} }
options.push("submission") options.push("submission")
return options return options
@@ -100,9 +101,9 @@ watch(currentTab, (tab) => {
}) })
watch( watch(
() => pinnedStore.isPinned, () => myFlowchartStore.showing,
(pinned) => { (showing) => {
if (pinned) currentTab.value = "pinned" if (showing) currentTab.value = "my-flowchart"
}, },
) )
@@ -124,7 +125,7 @@ onBeforeUnmount(() => {
problem.value = null problem.value = null
errMsg.value = "无数据" errMsg.value = "无数据"
screenModeStore.resetScreenMode() screenModeStore.resetScreenMode()
pinnedStore.unpin() myFlowchartStore.hide()
}) })
watch(isMobile, (value) => { watch(isMobile, (value) => {
@@ -171,11 +172,11 @@ watch(isMobile, (value) => {
<ProblemComment /> <ProblemComment />
</n-tab-pane> </n-tab-pane>
<n-tab-pane <n-tab-pane
v-if="pinnedStore.isPinned" v-if="myFlowchartStore.showing"
name="pinned" name="my-flowchart"
tab="我的流程图" tab="我的流程图"
> >
<PinnedFlowchartTab /> <MyFlowchartTab />
</n-tab-pane> </n-tab-pane>
<n-tab-pane <n-tab-pane
name="submission" name="submission"
@@ -211,13 +212,6 @@ watch(isMobile, (value) => {
> >
<ProblemFlowchart /> <ProblemFlowchart />
</n-tab-pane> </n-tab-pane>
<n-tab-pane
v-if="pinnedStore.isPinned"
name="pinned"
tab="我的流程图"
>
<PinnedFlowchartTab />
</n-tab-pane>
<n-tab-pane <n-tab-pane
name="info" name="info"
tab="题目统计" tab="题目统计"
@@ -233,6 +227,13 @@ watch(isMobile, (value) => {
> >
<ProblemComment /> <ProblemComment />
</n-tab-pane> </n-tab-pane>
<n-tab-pane
v-if="myFlowchartStore.showing"
name="my-flowchart"
tab="我的流程图"
>
<MyFlowchartTab />
</n-tab-pane>
<n-tab-pane <n-tab-pane
name="submission" name="submission"
tab="我的提交" tab="我的提交"
@@ -266,8 +267,8 @@ watch(isMobile, (value) => {
> >
<ProblemComment /> <ProblemComment />
</n-tab-pane> </n-tab-pane>
<n-tab-pane v-if="pinnedStore.isPinned" name="pinned" tab="我的流程图"> <n-tab-pane v-if="myFlowchartStore.showing" name="my-flowchart" tab="我的流程图">
<PinnedFlowchartTab /> <MyFlowchartTab />
</n-tab-pane> </n-tab-pane>
<n-tab-pane name="submission" tab="提交" :disabled="!!props.problemSetId"> <n-tab-pane name="submission" tab="提交" :disabled="!!props.problemSetId">
<ProblemSubmission /> <ProblemSubmission />

View File

@@ -0,0 +1,18 @@
import { defineStore } from "pinia"
export const useMyFlowchartStore = defineStore("myFlowchart", () => {
const showing = ref(false)
const mermaidCode = ref("")
function show(code: string) {
mermaidCode.value = code
showing.value = true
}
function hide() {
showing.value = false
mermaidCode.value = ""
}
return { showing, mermaidCode, show, hide }
})

View File

@@ -1,18 +0,0 @@
import { defineStore } from "pinia"
export const usePinnedFlowchartStore = defineStore("pinnedFlowchart", () => {
const isPinned = ref(false)
const mermaidCode = ref("")
function pin(code: string) {
mermaidCode.value = code
isPinned.value = true
}
function unpin() {
isPinned.value = false
mermaidCode.value = ""
}
return { isPinned, mermaidCode, pin, unpin }
})