From 9247edc215d8173debb41fcb677308c24630fea4 Mon Sep 17 00:00:00 2001 From: La123123 <617330105@qq.com> Date: Tue, 21 Apr 2026 15:07:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=9C=8D=E9=A1=B5=E9=9D=A2=E7=BF=BB?= =?UTF-8?q?=E8=AF=91=E5=8A=9F=E8=83=BD=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/LoginController.java | 15 ++++++-- im-web/src/components/chat/ChatBox.vue | 38 +++++++++++++++++++ 2 files changed, 50 insertions(+), 3 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 fba3da3..8375a18 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 @@ -75,13 +75,22 @@ public class LoginController { } @PostMapping("/getTranslate") - @Operation(summary = "获取配置", description = "用户注册") + @Operation(summary = "翻译文本", description = "翻译文本") public Result getTranslate(@RequestBody JSONObject jsonObject) { - System.out.println("1111111111"); String str = jsonObject.getStr("str"); - String trans = BaiduTranslationUtils.translate(str,"zh"); + if(str == null || str.isEmpty()){ + return ResultUtils.success("","success"); + } + //翻译目标国家 + String country = jsonObject.getStr("country"); + String trans = ""; + if(country == null || country.isEmpty()) { + trans = BaiduTranslationUtils.translate(str, "zh"); + }else{ + trans = BaiduTranslationUtils.translate(str, country); + } return ResultUtils.success(trans,"success"); } diff --git a/im-web/src/components/chat/ChatBox.vue b/im-web/src/components/chat/ChatBox.vue index f927c31..7b1212e 100644 --- a/im-web/src/components/chat/ChatBox.vue +++ b/im-web/src/components/chat/ChatBox.vue @@ -108,6 +108,23 @@ @submit="sendMessage" />