fix
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-09 01:38:21 -06:00
parent 3a1bf09a6a
commit 5890373f46
2 changed files with 12 additions and 3 deletions

View File

@@ -36,8 +36,13 @@ interface Evaluation extends Rating {
}
// ==================== 组合式函数和响应式变量 ====================
interface FlowchartEditorInstance {
getFlowchartData: () => { nodes: unknown[]; edges: unknown[] }
setFlowchartData: (data: { nodes: unknown[]; edges: unknown[] }) => void
}
// 通过inject获取FlowchartEditor组件的引用
const flowchartEditorRef = inject<any>("flowchartEditorRef")
const flowchartEditorRef = inject<Ref<FlowchartEditorInstance | null>>("flowchartEditorRef")
const mermaidContainer = useTemplateRef<HTMLElement>("mermaidContainer")
// 基础组合式函数
@@ -94,7 +99,7 @@ function subscribeToSubmission(submissionId: string) {
// ==================== 提交相关函数 ====================
// 提交流程图
async function submitFlowchartData(flowchartEditorRef: any) {
async function submitFlowchartData() {
if (!flowchartEditorRef?.value) return
// 获取流程图的JSON数据
@@ -138,7 +143,7 @@ async function submitFlowchartData(flowchartEditorRef: any) {
// 提交函数
function submit() {
submitFlowchartData(flowchartEditorRef)
submitFlowchartData()
}
// ==================== 数据获取和处理函数 ====================

View File

@@ -269,6 +269,7 @@ async function loadMermaid() {
export function useMermaid() {
const renderError = ref<string | null>(null)
const renderSuccess = ref(false)
let renderGeneration = 0
const renderFlowchart = async (
container: HTMLElement | null,
@@ -281,14 +282,17 @@ export function useMermaid() {
if (!container || !mermaidCode?.trim()) return
const gen = ++renderGeneration
try {
const m = await loadMermaid()
const id = `mermaid-${getRandomId()}`
const { svg } = await m.render(id, mermaidCode)
if (gen !== renderGeneration) return
container.innerHTML = svg
applyFlowchartDisplayStyle(container)
renderSuccess.value = true
} catch (error) {
if (gen !== renderGeneration) return
renderError.value =
error instanceof Error
? error.message