fix:如果英文武将名有空格资料卡会弹窗

This commit is contained in:
lieren2023 2024-03-22 14:24:48 +08:00 committed by GitHub
parent 1d845e574b
commit d04d43de33
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 4 deletions

View File

@ -41588,6 +41588,10 @@ var pinyin_dict_withtone = "yī,dīng zhēng,kǎo qiǎo yú,qī,shàng,xià,hǎn
* @param splitter 返回结果拼接字符 * @param splitter 返回结果拼接字符
*/ */
function parsePolyphone(chinese, result, splitter, withtone) { function parsePolyphone(chinese, result, splitter, withtone) {
// 先删除中文字符之外的所有字符(包括英文字母、数字、标点符号、空格和其他非中文字符),然后再查找多音字
chinese = chinese.replace(/[^\u4e00-\u9fa5]/g, '');
if(chinese.length == 0) return result;
var poly = window.pinyin_dict_polyphone; var poly = window.pinyin_dict_polyphone;
var max = 7; // 最多只考虑7个汉字的多音字词虽然词库里面有10个字的但是数量非常少为了整体效率暂时忽略之 var max = 7; // 最多只考虑7个汉字的多音字词虽然词库里面有10个字的但是数量非常少为了整体效率暂时忽略之
var temp = poly[chinese]; var temp = poly[chinese];
@ -41604,10 +41608,6 @@ var pinyin_dict_withtone = "yī,dīng zhēng,kǎo qiǎo yú,qī,shàng,xià,hǎn
for (var i = 0; i < chinese.length;(i++,m++)) { for (var i = 0; i < chinese.length;(i++,m++)) {
temp = ''; temp = '';
for (var j = 0; j < max && (i + j) < chinese.length; j++) { for (var j = 0; j < max && (i + j) < chinese.length; j++) {
if (!dict.withtone[chinese[i]]) {
i+=(result[m].length-1);
break;
} // 如果碰到非汉字直接停止本次查找
temp += chinese[i + j]; temp += chinese[i + j];
var res = poly[temp]; var res = poly[temp];
if (res) // 如果找到了多音字词语 if (res) // 如果找到了多音字词语