This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user