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 +})