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