From 70911f87af7f7c16b28361aadafd3044a61ea4d1 Mon Sep 17 00:00:00 2001 From: windy <1374721899@qq.com> Date: Fri, 19 Jul 2019 17:11:28 +0800 Subject: [PATCH] =?UTF-8?q?BI-47579=20refactor:=20=E5=8F=96=E9=A6=96?= =?UTF-8?q?=E5=AD=97=E6=AF=8D=E6=8B=BC=E9=9F=B3=E5=8F=AF=E9=80=89=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E9=9C=80=E8=A6=81=E6=8B=BC=E6=8E=A5=E5=A4=9A=E9=9F=B3?= =?UTF-8?q?=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/utils/chinesePY.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/utils/chinesePY.js b/src/core/utils/chinesePY.js index 652ad3b2f3..de53fc1bf5 100644 --- a/src/core/utils/chinesePY.js +++ b/src/core/utils/chinesePY.js @@ -387,14 +387,14 @@ return (oMultiDiff[uni] ? oMultiDiff[uni] : (_ChineseFirstPY.charAt(uni - 19968))); }; - var _mkPYRslt = function (arr) { + var _mkPYRslt = function (arr, ignoreMulti) { var arrRslt = [""], k, multiLen = 0; for (var i = 0, len = arr.length; i < len; i++) { var str = arr[i]; var strlen = str.length; // 多音字过多的情况下,指数增长会造成浏览器卡死,超过20完全卡死,18勉强能用,考虑到不同性能最好是16或者14 // 超过14个多音字之后,后面的都用第一个拼音 - if (strlen == 1 || multiLen > 14) { + if (strlen == 1 || multiLen > 14 || ignoreMulti) { var tmpStr = str.substring(0, 1); for (k = 0; k < arrRslt.length; k++) { arrRslt[k] += tmpStr; @@ -419,7 +419,8 @@ }; _.extend(BI, { - makeFirstPY: function (str) { + makeFirstPY: function (str, options) { + options = options || {}; if (typeof (str) !== "string") {return "" + str;} var arrResult = []; // 保存中间结果的数组 for (var i = 0, len = str.length; i < len; i++) { @@ -429,7 +430,7 @@ arrResult.push(_checkPYCh(ch)); } // 处理arrResult,返回所有可能的拼音首字母串数组 - return _mkPYRslt(arrResult); + return _mkPYRslt(arrResult, options.ignoreMulti); } }); })(); \ No newline at end of file