修复密码管理器获取拼音出错的bug

This commit is contained in:
Yutousama 2022-01-20 14:09:11 +08:00
parent 4524b6f2c3
commit c7bcce309b
2 changed files with 5 additions and 9 deletions

View File

@ -5,7 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @SpringBootApplication
public class ToolsApplication { public class ToolsApplication {
public static final String version="1.4.3"; public static final String version="1.4.4.1";
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("当前版本号:" + version); System.out.println("当前版本号:" + version);

View File

@ -456,14 +456,10 @@ public class Tools {
} }
public static String getPinYin(String text) { public static String getPinYin(String text) {
try { String pinyin = HttpTools.get("http://api.tianapi.com/pinyin/index?key=a1e0f7267037c4e0ea02fb1cb3912367&text=" + URLEncoder.encode(text, StandardCharsets.UTF_8));
String pinyin = HttpTools.get("http://api.tianapi.com/pinyin/index?key=a1e0f7267037c4e0ea02fb1cb3912367&text=" + URLEncoder.encode(text, "UTF-8")); JSONObject json = JSONObject.parseObject(pinyin);
JSONObject json = JSONObject.parseObject(pinyin); if (json.getInteger("code") == 200) {
if (json.getInteger("code") == 200) { return json.getJSONArray("newslist").getJSONObject(0).getString("pinyin").trim().replace(" ", "");
return json.getJSONObject("newslist").getString("pinyin").trim().replace(" ", "");
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} }
return ""; return "";
} }