Browse Source

refactor(yvan-lcc):优化 JsDemo 页面的代码执行逻辑

- 在代码模板中添加示例日志输出和日期对象- 优化 execute 函数的异步处理结构
- 调整代码格式,提高可读性
master
lizw-2015 6 months ago
parent
commit
4a1963c57f
  1. 7
      src/pages/JsDemo.vue

7
src/pages/JsDemo.vue

@ -5,11 +5,14 @@ import YvSrcEditor from "../components/YvSrcEditor.vue"
const code = ref(`
log.info("测试打印日志,通过服务端控制台查看")
const a = 111, b= 555;
const sum = (a + b);
print(a + "+" + b + " = " + sum);
return {
sum,
date: new Date(),
msg: "测试JS脚本",
}
`);
@ -19,9 +22,9 @@ const res = ref("");
function execute() {
Request.request.post("/api/workbench/JsDemo@runJs", {
jsCode: code.value,
}).then(data=> {
}).then(data => {
res.value = JSON.stringify(data, null, 4);
}).catch(()=> {
}).catch(() => {
res.value = "执行失败";
});
}

Loading…
Cancel
Save