Browse Source

客服页面翻译功能样式

master
La123123 4 weeks ago
parent
commit
9247edc215
  1. 15
      im-platform/src/main/java/com/bx/implatform/controller/LoginController.java
  2. 38
      im-web/src/components/chat/ChatBox.vue

15
im-platform/src/main/java/com/bx/implatform/controller/LoginController.java

@ -75,13 +75,22 @@ public class LoginController {
} }
@PostMapping("/getTranslate") @PostMapping("/getTranslate")
@Operation(summary = "获取配置", description = "用户注册") @Operation(summary = "翻译文本", description = "翻译文本")
public Result getTranslate(@RequestBody JSONObject jsonObject) { public Result getTranslate(@RequestBody JSONObject jsonObject) {
System.out.println("1111111111");
String str = jsonObject.getStr("str"); 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"); return ResultUtils.success(trans,"success");
} }

38
im-web/src/components/chat/ChatBox.vue

@ -108,6 +108,23 @@
@submit="sendMessage" @submit="sendMessage"
/> />
<div class="send-btn-area"> <div class="send-btn-area">
<el-select
v-model="countryCode"
style="width: 110px; margin-right: 10px"
size="small"
>
<el-option
v-for="item in countryCodeList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
<el-button
type="primary"
@click="translateMessage(countryCode)"
>翻译</el-button
>
<el-button <el-button
type="primary" type="primary"
icon="el-icon-s-promotion" icon="el-icon-s-promotion"
@ -321,6 +338,18 @@ export default {
newMessageSize: 0, newMessageSize: 0,
ipLocation: "", ipLocation: "",
maxTmpId: 0, maxTmpId: 0,
countryCode: "en",
countryCodeList: [
{ label: "英语", value: "en" },
{ label: "日语", value: "jp" },
{ label: "韩语", value: "kor" },
{ label: "越南语", value: "vie" },
{ label: "俄语", value: "ru" },
{ label: "德语", value: "de" },
{ label: "法语", value: "fra" },
{ label: "葡萄牙语", value: "pt" },
{ label: "阿拉伯语", value: "ara" },
],
}; };
}, },
methods: { methods: {
@ -1285,6 +1314,15 @@ export default {
}); });
return res; return res;
}, },
//
async translateTextToOther(text, country) {
const res = await this.$http({
url: "/getTranslate",
method: "post",
data: { str: text, country: country },
});
return res;
},
}, },
computed: { computed: {
mine() { mine() {

Loading…
Cancel
Save