From 4a1963c57fa3f05dc476f188147667d7a0e82d05 Mon Sep 17 00:00:00 2001 From: lizw-2015 <1183409807@qq.com> Date: Thu, 19 Jun 2025 12:15:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor(yvan-lcc):=E4=BC=98=E5=8C=96=20JsDemo?= =?UTF-8?q?=20=E9=A1=B5=E9=9D=A2=E7=9A=84=E4=BB=A3=E7=A0=81=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在代码模板中添加示例日志输出和日期对象- 优化 execute 函数的异步处理结构 - 调整代码格式,提高可读性 --- src/pages/JsDemo.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pages/JsDemo.vue b/src/pages/JsDemo.vue index fff3a71..3d0cb9c 100644 --- a/src/pages/JsDemo.vue +++ b/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 = "执行失败"; }); }