update 文档管理html 文本翻译改为腾讯云机器翻译服务器api,优化翻译逻辑,减少翻译量

This commit is contained in:
yyb
2025-08-12 17:09:06 +08:00
parent 95573662ff
commit 94899a4baa
8 changed files with 297 additions and 144 deletions

View File

@@ -401,7 +401,6 @@ public class PoolServiceImpl implements PoolService {
List<PowerLineDto> list = poolMapper.getHourNetPowerList(pool.getCoin());
System.out.println("list----yyb-1"+list);
if("1h".equals(vo.getInterval()) || "rt".equals(vo.getInterval())){
PageHelper.clearPage();
//30m数据 限制条数为最近1天的条数 即1*48=48

View File

@@ -1,5 +1,6 @@
package com.m2pool.pool.utils;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import com.m2pool.common.core.utils.DateUtils;
@@ -41,6 +42,37 @@ public class SocketDemo {
//Date endDate = DateUtils.getPreviousHalfHourOrFullHour(new Date());
//Date startDate = DateUtils.getOneMonthAgo(endDate);
//System.out.println(startDate+" "+endDate);
String textToTranslate = "<p _msthidden=\"3\"><span style=\"color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);\" _msttexthash=\"84072040\" _msthash=\"1610\">API 中 coin 字段可目前仅取值支持nexa</span></p><p _msthidden=\"3\"><span id=\"step\"></span></p><h3 style=\"text-align: start;\" _msttexthash=\"11282648\" _msthash=\"1609\">矿池信息</h3><h3 style=\"text-align: start;\" _msthidden=\"3\"><span style=\"font-size: 16px;\" _msttexthash=\"11308739\" _msthash=\"1608\">公共结构</span></h3><p style=\"text-align: start;\" _msthidden=\"3\"><strong _msttexthash=\"7939243\" _msthash=\"1607\">哈希率</strong></p><p style=\"text-align: start;\" _msttexthash=\"11425713\" _msthash=\"1606\">算力数据</p><p style=\"text-align: start;\" _msthidden=\"3\"><br/></p><table style=\"width: auto;\" _msthidden=\"3\"><tbody><tr><th colspan=\"1\" rowspan=\"1\" width=\"120\" _msttexthash=\"5204511\" _msthash=\"1596\">名称</th><th colspan=\"1\" rowspan=\"1\" width=\"99.03\" _msttexthash=\"5230641\" _msthash=\"1597\">类型</th><th colspan=\"1\" rowspan=\"1\" width=\"117\" style=\"text-align: center;\" _msttexthash=\"4973501\" _msthash=\"1598\">备注</th><th colspan=\"1\" rowspan=\"1\" width=\"186\" style=\"text-align: center;\" _msttexthash=\"7093697\" _msthash=\"1599\">解释</th></tr><tr><td colspan=\"1\" rowspan=\"1\" width=\"auto\" style=\"text-align: center;\"><font _mstmutation=\"1\" _msttexthash=\"5119231\" _msthash=\"1600\">日期</font><br/></td><td colspan=\"1\" rowspan=\"1\" width=\"auto\" style=\"text-align: center;\" _msttexthash=\"5119231\" _msthash=\"1601\">日期</td><td colspan=\"1\" rowspan=\"1\" width=\"auto\"></td><td colspan=\"1\" rowspan=\"1\" width=\"auto\" style=\"text-align: center;\" _msttexthash=\"23246444\" _msthash=\"1602\">算力统计时间</td></tr><tr><td colspan=\"1\" rowspan=\"1\" width=\"auto\" style=\"text-align: center;\"><font _mstmutation=\"1\" _msttexthash=\"5078437\" _msthash=\"1603\">算力</font><br/></td><td colspan=\"1\" rowspan=\"1\" width=\"auto\" style=\"text-align: center;\"><font _mstmutation=\"1\" _msttexthash=\"1952132\" _msthash=\"1604\">双</font><br/></td><td colspan=\"1\" rowspan=\"1\" width=\"auto\"></td><td colspan=\"1\" rowspan=\"1\" width=\"auto\" style=\"text-align: center;\"><font _mstmutation=\"1\" _msttexthash=\"5078437\" _msthash=\"1605\">算力</font><br/></td></tr></tbody></table><p _msthidden=\"3\"><span id=\"MinersList\"></span></p><p _msthidden=\"3\"><span style=\"color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);\" _msttexthash=\"10586056\" _msthash=\"1595\">矿工名单</span></p><p _msthidden=\"3\"><span style=\"color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);\" _msttexthash=\"20870291\" _msthash=\"1594\">矿工数量数据</span></p><table style=\"width: auto;\" _msthidden=\"3\"><tbody><tr><th colspan=\"1\" rowspan=\"1\" width=\"148.7\" style=\"text-align: center;\" _msttexthash=\"5204511\" _msthash=\"1581\">名称</th><th colspan=\"1\" rowspan=\"1\" width=\"99\" style=\"text-align: center;\" _msttexthash=\"5230641\" _msthash=\"1582\">类型</th><th colspan=\"1\" rowspan=\"1\" width=\"111\" style=\"text-align: center;\" _msttexthash=\"4973501\" _msthash=\"1583\">备注</th><th colspan=\"1\" rowspan=\"1\" width=\"153\" style=\"text-align: center;\" _msttexthash=\"7093697\" _msthash=\"1584\">解释</th></tr><tr><td colspan=\"1\" rowspan=\"1\" width=\"auto\" style=\"text-align: center;\" _msttexthash=\"2241785\" _msthash=\"1585\">总</td><td colspan=\"1\" rowspan=\"1\" width=\"auto\" style=\"text-align: center;\" _msttexthash=\"5064124\" _msthash=\"1586\">整数</td><td colspan=\"1\" rowspan=\"1\" width=\"auto\">"; // 替换为实际要翻译的文本
String apiKey = ""; // 替换为实际的 API 密钥
String response = translate(textToTranslate, apiKey);
System.out.println(response);
}
/**
* 发送翻译请求
* @param text 待翻译的文本
* @param apiKey API 密钥
* @return 响应结果字符串
*/
public static String translate(String text, String apiKey) {
// 构建请求体
JSONObject requestBody = new JSONObject();
requestBody.put("q", text);
requestBody.put("source", "auto");
requestBody.put("target", "zh");
requestBody.put("format", "text");
requestBody.put("alternatives", 3);
requestBody.put("api_key", apiKey);
// 发送 POST 请求
String result = HttpRequest.post("https://libretranslate.com/translate")
.header("Content-Type", "application/json")
.body(requestBody.toString())
.execute()
.body();
return result;
}
}