Browse Source

init

master
lizw-2015 6 months ago
parent
commit
fa669b3209
  1. 47
      src/pages/JsDemo.vue
  2. 7
      src/router/index.ts

47
src/pages/JsDemo.vue

@ -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>

7
src/router/index.ts

@ -33,7 +33,12 @@ const router = createRouter({
path: '/DataForm01',
name: 'DataForm01',
component: () => import('@/pages/DataForm01.vue')
}
},
{
path: '/JsDemo',
name: 'JsDemo',
component: () => import('@/pages/JsDemo.vue')
},
]
})

Loading…
Cancel
Save