From aa928dd3f5371ec844f5ef9f063bb37634df05e8 Mon Sep 17 00:00:00 2001 From: yuetsh <517252939@qq.com> Date: Mon, 7 Sep 2026 04:46:01 -0600 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B0=83=E8=AF=95=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=A7=BB=E5=8A=A8=E7=AB=AF=EF=BC=8C=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E6=8C=89=E4=BD=9C=E7=94=A8=E5=9F=9F=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 调试逻辑下沉到 composables/debug.ts,桌面和移动端共用;模态框抽成 DebugModal.vue(桌面 80vw / 移动 96vw),用 update:show 收口, 关闭按钮、Esc、遮罩三条路径都会清理状态 - 移动端在"操作"菜单里补上调试入口(仅 Python) - 变量面板改为分组展示:栈顶帧的局部变量在前、全局变量在后, 顺序用 pg_encoder 的 ordered_globals / ordered_varnames, __return__ 显示成"返回值"。原来两者是 merge 成一份的, 在函数里分不清哪个是局部、哪个是外面的全局 - 面板关闭时还原全局 output / status,否则主页输出区会停在某一调试步 - 输入切分不再过滤空行,只丢掉末尾换行产生的空串:程序可能正需要读一个 空行,过滤掉会让输入提前耗尽、误报"需要更多输入" - 后端超时/超限的 detail 透传到提示里,调试按钮加 loading 态 - 清掉 computed 和高亮更新里遗留的 console.log(自动播放时 500ms 刷一次) Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_019QGZaLUWzGPEMTk6A5RShC --- src/components/DebugEditor.vue | 7 -- src/components/DebugModal.vue | 27 +++++ src/components/DebugPanel.vue | 184 ++++++++++++++++++++------------- src/composables/debug.ts | 74 +++++++++++++ src/desktop/CodeSection.vue | 64 ++---------- src/mobile/Header.vue | 29 +++++- src/mobile/index.vue | 2 + 7 files changed, 245 insertions(+), 142 deletions(-) create mode 100644 src/components/DebugModal.vue create mode 100644 src/composables/debug.ts diff --git a/src/components/DebugEditor.vue b/src/components/DebugEditor.vue index fe9196c..6ad09d4 100644 --- a/src/components/DebugEditor.vue +++ b/src/components/DebugEditor.vue @@ -214,13 +214,6 @@ function onReady(payload: { // 更新高亮的函数 function updateHighlight() { if (editorView.value) { - console.log( - "Updating highlight - currentLine:", - props.currentLine, - "nextLine:", - props.nextLine, - ) - // 如果当前行和下一步相同,只高亮当前行,不显示下一步 const nextLine = props.currentLine === props.nextLine ? undefined : props.nextLine diff --git a/src/components/DebugModal.vue b/src/components/DebugModal.vue new file mode 100644 index 0000000..7767af6 --- /dev/null +++ b/src/components/DebugModal.vue @@ -0,0 +1,27 @@ + + + diff --git a/src/components/DebugPanel.vue b/src/components/DebugPanel.vue index 2be1a9f..1953d7b 100644 --- a/src/components/DebugPanel.vue +++ b/src/components/DebugPanel.vue @@ -1,6 +1,6 @@ @@ -84,7 +46,8 @@ async function handleDebug() { v-if="code.language === 'python'" quaternary type="error" - :disabled="!code.value" + :loading="debugLoading" + :disabled="!code.value || debugLoading" @click="handleDebug" > 调试 @@ -92,16 +55,5 @@ async function handleDebug() { - - - + diff --git a/src/mobile/Header.vue b/src/mobile/Header.vue index 87f8b20..23cebdf 100644 --- a/src/mobile/Header.vue +++ b/src/mobile/Header.vue @@ -2,7 +2,9 @@ import { Icon } from "@iconify/vue" import copyTextToClipboard from "copy-text-to-clipboard" import { useMessage, type DropdownOption } from "naive-ui" +import { computed } from "vue" import { code, loading, reset, run, share } from "../composables/code" +import { debugLoading, startDebug } from "../composables/debug" import { tab } from "../composables/tab" const message = useMessage() @@ -24,11 +26,28 @@ function handleShare() { } } -const menu: DropdownOption[] = [ - { label: "复制", key: "copy", props: { onClick: copy } }, - { label: "清空", key: "reset", props: { onClick: reset } }, - { label: "分享", key: "share", props: { onClick: handleShare } }, -] +async function handleDebug() { + const result = await startDebug() + if (!result.ok) message[result.level](result.message) +} + +const menu = computed(() => { + const options: DropdownOption[] = [ + { label: "复制", key: "copy", props: { onClick: copy } }, + { label: "清空", key: "reset", props: { onClick: reset } }, + { label: "分享", key: "share", props: { onClick: handleShare } }, + ] + // 调试只支持 Python,跟桌面端的按钮保持一致 + if (code.language === "python") { + options.push({ + label: debugLoading.value ? "调试中…" : "调试", + key: "debug", + disabled: debugLoading.value || !code.value, + props: { onClick: handleDebug }, + }) + } + return options +})