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" />