From 27668f8fee850f7f3476742c08157c642510db63 Mon Sep 17 00:00:00 2001 From: yutent Date: Mon, 21 Mar 2022 18:23:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E7=A0=81=E8=A7=84?= =?UTF-8?q?=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/lib/core.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/js/lib/core.js b/js/lib/core.js index 496ba5b..71cf144 100644 --- a/js/lib/core.js +++ b/js/lib/core.js @@ -35,13 +35,27 @@ export function createCode(dict, word) { break } } + + case 4: { + let c1 = dict.get(word[0])?.pop() + let c2 = dict.get(word[1])?.pop() + let c3 = dict.get(word[2])?.pop() + let c4 = dict.get(word[3])?.pop() + if (c1 && c2 && c3 && c4) { + return c1[0] + c2[0] + c3[0] + c4[0] + } else { + console.error(word, '词组中存在未收录单字, 请到github上提交issues') + break + } + } + default: { let c1 = dict.get(word[0])?.pop() let c2 = dict.get(word[1])?.pop() let ce = dict.get(word[word.length - 1])?.pop() if (c1 && c2 && ce) { - return c1.slice(0, 1) + c2.slice(0, 1) + ce.slice(0, 2) + return c1[0] + c2[0] + ce.slice(0, 2) } else { console.error(word, '词组中存在未收录单字, 请到github上提交issues') break