fix
Some checks failed
Deploy / build-and-deploy (push) Has been cancelled

This commit is contained in:
2025-10-21 21:54:59 +08:00
parent e96611c62b
commit 53ae1a8ef8
3 changed files with 29 additions and 0 deletions

View File

@@ -70,3 +70,11 @@ export async function createCode(data: { code: string; query: string }) {
export async function removeCode(id: number) {
await api.delete(`/${id}`)
}
export async function debug(code: string, inputs: string[]) {
const res = await api.post("/debug", {
code,
inputs,
})
return res.data
}

View File

@@ -13,6 +13,9 @@ export async function getAIAnalysis() {
try {
const response = await fetch(`${baseUrl}/ai`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
code: code.value,
language: code.language,

View File

@@ -3,6 +3,7 @@ import copyTextToClipboard from "copy-text-to-clipboard"
import { useMessage } from "naive-ui"
import { computed, watch, useTemplateRef } from "vue"
import { marked } from "marked"
import { debug as debugApi } from "../api"
// @ts-ignore
import * as Sk from "skulpt"
import CodeEditor from "../components/CodeEditor.vue"
@@ -35,6 +36,13 @@ function copy() {
function handleDebug() {
debug.value = true
}
async function handleDebugNew() {
const inputs = input.value ? input.value.split("\n") : []
const res = await debugApi(code.value, inputs)
console.log(res.data)
}
const turtleCanvas = useTemplateRef("turtle")
function builtinRead(x: any) {
@@ -96,6 +104,16 @@ watch(turtleRunId, () => runSkulptTurtle())
>
调试
</n-button>
<n-button
quaternary
type="error"
:disabled="!code.value"
v-if="false && code.language === 'python'"
@click="handleDebugNew"
>
调试
</n-button>
<n-button quaternary type="primary" @click="copy">复制</n-button>
<n-button quaternary @click="reset">清空</n-button>
</template>