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

This commit is contained in:
2025-10-23 16:12:42 +08:00
parent 42ce9ac63b
commit 0a31cc3d2f
22 changed files with 318 additions and 257 deletions

View File

@@ -25,7 +25,8 @@ const { problem } = storeToRefs(problemStore)
const route = useRoute()
const contestID = <string>route.params.contestID ?? ""
const problemSetId = <string>route.params.problemSetId ?? ""
console.log(problemSetId, "problemSetId")
const router = useRouter()
const [commentPanel] = useToggle()
const { isDesktop } = useBreakpoints()
@@ -61,6 +62,19 @@ const { start: showCommentPanelDelayed } = useTimeoutFn(
{ immediate: false },
)
const { start: goToProblemSetDelayed } = useTimeoutFn(
() => {
router.push({
name: "problemset",
params: {
problemSetId: problemSetId,
},
})
},
1500,
{ immediate: false },
)
// ==================== 计算属性 ====================
// 按钮禁用逻辑
const submitDisabled = computed(() => {
@@ -121,15 +135,11 @@ watch(
// 2. 创建ProblemSetSubmission记录更新题单进度
if (problemSetId) {
try {
await updateProblemSetProgress(
Number(problemSetId),
problem.value!.id,
submission.value!.id,
)
} catch (error) {
console.error("更新题单进度失败:", error)
}
await updateProblemSetProgress(
Number(problemSetId),
problem.value!.id,
submission.value!.id,
)
}
// 3. 放烟花
@@ -139,6 +149,11 @@ watch(
if (!contestID && !problemSetId) {
showCommentPanelDelayed()
}
if (problemSetId) {
// 延迟回到题单页面
goToProblemSetDelayed()
}
},
)
</script>

View File

@@ -14,7 +14,11 @@ import {
} from "shared/composables/websocket"
// API 和状态管理
import { getCurrentProblemFlowchartSubmission, submitFlowchart, updateProblemSetProgress } from "oj/api"
import {
getCurrentProblemFlowchartSubmission,
submitFlowchart,
updateProblemSetProgress,
} from "oj/api"
import { useProblemStore } from "oj/store/problem"
// ==================== 类型定义 ====================

View File

@@ -104,7 +104,7 @@ export function useSubmissionMonitor() {
// ==================== 启动监控 ====================
const startMonitoring = (id: string) => {
submissionId.value = id
submission.value = { result: 9 } as Submission // 9 = submitting
submission.value = { id, result: 9 } as Submission // 9 = submitting
// 取消之前的断开计划
cancelScheduledDisconnect()
@@ -116,13 +116,16 @@ export function useSubmissionMonitor() {
}
// 等待WebSocket连接并订阅
const unwatch = watch(
let unwatch: (() => void) | null = null
unwatch = watch(
wsStatus,
(status) => {
if (status === "connected") {
console.log("[SubmissionMonitor] WebSocket已连接订阅提交:", id)
subscribe(id)
unwatch() // 订阅成功后停止监听
if (unwatch) {
unwatch() // 订阅成功后停止监听
}
}
},
{ immediate: true },