2 changed files with 53 additions and 1 deletions
@ -0,0 +1,47 @@ |
|||
<script setup lang="ts"> |
|||
import { ref } from "vue"; |
|||
import { Request } from "@ease-forge/shared"; |
|||
import YvSrcEditor from "../components/YvSrcEditor.vue" |
|||
|
|||
const code = ref(` |
|||
|
|||
const a = 111, b= 555; |
|||
const sum = (a + b); |
|||
print(a + "+" + b + " = " + sum); |
|||
|
|||
return { |
|||
msg: "测试JS脚本", |
|||
} |
|||
`); |
|||
|
|||
const res = ref(""); |
|||
|
|||
function execute() { |
|||
Request.request.post("/api/workbench/JsDemo@runJs", { |
|||
jsCode: code.value, |
|||
}).then(data=> { |
|||
res.value = JSON.stringify(data, null, 4); |
|||
}).catch(()=> { |
|||
res.value = "执行失败"; |
|||
}); |
|||
} |
|||
|
|||
</script> |
|||
|
|||
<template> |
|||
<div class="editor"> |
|||
<YvSrcEditor ref="jsEditor" language="javascript" v-model="code"/> |
|||
</div> |
|||
<button @click="execute" style="width: 80px;">执行</button> |
|||
<pre class="res">{{ res }}</pre> |
|||
</template> |
|||
|
|||
<style scoped> |
|||
.editor { |
|||
height: 600px; |
|||
} |
|||
|
|||
.res { |
|||
height: 300px; |
|||
} |
|||
</style> |
|||
Loading…
Reference in new issue