From fb9bfdff9637efacf030dff7b009854745775bcc Mon Sep 17 00:00:00 2001 From: La123123 <617330105@qq.com> Date: Fri, 8 May 2026 16:50:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E6=96=B9=E6=B3=95=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/LoginController.java | 43 ++++++------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/im-platform/src/main/java/com/bx/implatform/controller/LoginController.java b/im-platform/src/main/java/com/bx/implatform/controller/LoginController.java index aa4c584..f6eebda 100644 --- a/im-platform/src/main/java/com/bx/implatform/controller/LoginController.java +++ b/im-platform/src/main/java/com/bx/implatform/controller/LoginController.java @@ -99,41 +99,22 @@ public class LoginController { str = str.replace("\n", ""); //翻译目标国家 - String country = jsonObject.getStr("country"); + String country = jsonObject.getStr("country","zh"); String trans = ""; //如果代理有配置,则使用代理的配置 String translateType = settingService.translateType(); - switch (translateType) { - case "0"://默认使用系统自带的百度翻译 - if (country == null || country.isEmpty()) { - trans = baiduTranslationUtils.translate(str, "zh"); - } else { - trans = baiduTranslationUtils.translate(str, country); - } - break; - case "1": - if (country == null || country.isEmpty()) { - trans = baiduTranslationUtils.translateByAgentConfiguration(str, "zh"); - } else { - trans = baiduTranslationUtils.translateByAgentConfiguration(str, country); - } - break; - case "2": - if (country == null || country.isEmpty()) { - trans = youDaoTranslationUtils.translateByAgentConfiguration(str, "zh"); - } else { - trans = youDaoTranslationUtils.translateByAgentConfiguration(str, country); - } - break; - case "3": - if (country == null || country.isEmpty()) { - trans = googleTranslationUtils.translateByAgentConfiguration(str, "zh"); - } else { - trans = googleTranslationUtils.translateByAgentConfiguration(str, country); - } - break; - } + trans = switch (translateType) { + case "0" ->//默认使用系统自带的百度翻译 + baiduTranslationUtils.translate(str, country); + case "1" ->//使用百度翻译 + baiduTranslationUtils.translateByAgentConfiguration(str, country); + case "2" ->//使用有道翻译 + youDaoTranslationUtils.translateByAgentConfiguration(str, country); + case "3" ->//使用谷歌翻译 + googleTranslationUtils.translateByAgentConfiguration(str, country); + default -> trans; + }; return ResultUtils.success(trans,"success"); }