diff --git a/core/src/main/generated/cn/qaiu/vx/core/verticle/conf/HttpProxyConfConverter.java b/core/src/main/generated/cn/qaiu/vx/core/verticle/conf/HttpProxyConfConverter.java deleted file mode 100644 index 17b355a..0000000 --- a/core/src/main/generated/cn/qaiu/vx/core/verticle/conf/HttpProxyConfConverter.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.qaiu.vx.core.verticle.conf; - -import io.vertx.core.json.JsonObject; -import io.vertx.core.json.JsonArray; -import io.vertx.core.json.impl.JsonUtil; -import java.time.Instant; -import java.time.format.DateTimeFormatter; -import java.util.Base64; - -/** - * Converter and mapper for {@link cn.qaiu.vx.core.verticle.conf.HttpProxyConf}. - * NOTE: This class has been automatically generated from the {@link cn.qaiu.vx.core.verticle.conf.HttpProxyConf} original class using Vert.x codegen. - */ -public class HttpProxyConfConverter { - - - private static final Base64.Decoder BASE64_DECODER = JsonUtil.BASE64_DECODER; - private static final Base64.Encoder BASE64_ENCODER = JsonUtil.BASE64_ENCODER; - - static void fromJson(Iterable> json, HttpProxyConf obj) { - for (java.util.Map.Entry member : json) { - switch (member.getKey()) { - case "password": - if (member.getValue() instanceof String) { - obj.setPassword((String)member.getValue()); - } - break; - case "port": - if (member.getValue() instanceof Number) { - obj.setPort(((Number)member.getValue()).intValue()); - } - break; - case "preProxyOptions": - if (member.getValue() instanceof JsonObject) { - obj.setPreProxyOptions(new io.vertx.core.net.ProxyOptions((io.vertx.core.json.JsonObject)member.getValue())); - } - break; - case "timeout": - if (member.getValue() instanceof Number) { - obj.setTimeout(((Number)member.getValue()).intValue()); - } - break; - case "username": - if (member.getValue() instanceof String) { - obj.setUsername((String)member.getValue()); - } - break; - } - } - } - - static void toJson(HttpProxyConf obj, JsonObject json) { - toJson(obj, json.getMap()); - } - - static void toJson(HttpProxyConf obj, java.util.Map json) { - if (obj.getPassword() != null) { - json.put("password", obj.getPassword()); - } - if (obj.getPort() != null) { - json.put("port", obj.getPort()); - } - if (obj.getPreProxyOptions() != null) { - json.put("preProxyOptions", obj.getPreProxyOptions().toJson()); - } - if (obj.getTimeout() != null) { - json.put("timeout", obj.getTimeout()); - } - if (obj.getUsername() != null) { - json.put("username", obj.getUsername()); - } - } -} diff --git a/web-front/src/utils/tsCompiler.js b/web-front/src/utils/tsCompiler.js index bc2c2a4..f117947 100644 --- a/web-front/src/utils/tsCompiler.js +++ b/web-front/src/utils/tsCompiler.js @@ -19,7 +19,7 @@ export function compileToES5(sourceCode, fileName = 'script.ts') { module: ts.ModuleKind.None, // 不使用模块系统 lib: ['lib.es5.d.ts', 'lib.dom.d.ts'], // 包含ES5和DOM类型定义 removeComments: false, // 保留注释 - noEmitOnError: false, // 即使有错误也生成代码 + noEmitOnError: true, // 有错误时不生成代码 noImplicitAny: false, // 允许隐式any类型 strictNullChecks: false, // 不进行严格的null检查 suppressImplicitAnyIndexErrors: true, // 抑制隐式any索引错误 diff --git a/web-front/src/views/Playground.vue b/web-front/src/views/Playground.vue index f90e53f..cf5c31e 100644 --- a/web-front/src/views/Playground.vue +++ b/web-front/src/views/Playground.vue @@ -7,8 +7,8 @@ JS解析器演练场 - JavaScript - TypeScript + JavaScript + TypeScript
@@ -496,9 +496,15 @@ export default { Pane }, setup() { + // 语言常量 + const LANGUAGE = { + JAVASCRIPT: 'JavaScript', + TYPESCRIPT: 'TypeScript' + }; + const editorRef = ref(null); const jsCode = ref(''); - const codeLanguage = ref('JavaScript'); // 新增:代码语言选择 + const codeLanguage = ref(LANGUAGE.JAVASCRIPT); // 新增:代码语言选择 const compiledES5Code = ref(''); // 新增:编译后的ES5代码 const compileStatus = ref({ success: true, errors: [] }); // 新增:编译状态 const testParams = ref({ @@ -758,7 +764,7 @@ async function parseById( // 加载示例代码 const loadTemplate = () => { - jsCode.value = codeLanguage.value === 'TypeScript' ? exampleTypeScriptCode : exampleCode; + jsCode.value = codeLanguage.value === LANGUAGE.TYPESCRIPT ? exampleTypeScriptCode : exampleCode; ElMessage.success(`已加载${codeLanguage.value}示例代码`); }; @@ -897,8 +903,9 @@ async function parseById( // 确定要执行的代码(TypeScript需要先编译) let codeToExecute = jsCode.value; - // 如果是TypeScript模式或代码看起来像TypeScript,先编译 - if (codeLanguage.value === 'TypeScript' || isTypeScriptCode(jsCode.value)) { + // 优先使用显式语言选择,如果是JavaScript模式但代码是TS,给出提示 + if (codeLanguage.value === LANGUAGE.TYPESCRIPT) { + // TypeScript模式:始终编译 try { const compileResult = compileToES5(jsCode.value); @@ -943,6 +950,12 @@ async function parseById( }; return; } + } else if (isTypeScriptCode(jsCode.value)) { + // JavaScript模式但检测到TypeScript语法:给出提示 + ElMessage.warning({ + message: '检测到TypeScript语法,建议切换到TypeScript模式', + duration: 3000 + }); } try { @@ -1419,6 +1432,7 @@ curl "${baseUrl}/json/parser?url=${encodeURIComponent(exampleUrl)}" }); return { + LANGUAGE, editorRef, jsCode, codeLanguage,