Skip to content

Commit

Permalink
#24 用之后内容替换第一项的...
Browse files Browse the repository at this point in the history
  • Loading branch information
testacount1 committed Mar 7, 2019
1 parent ff4f812 commit 9b68a1a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/查词.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ function 逐词翻译(选中文本, 所有词条, 所有词): string {
let 下一词 = 所有词[序号];
let 位置 = 释义.indexOf(下一词);

if (位置 == 0) {
各释义.push("");
} else {
if (位置 > 0) {
各释义.push(释义.substring(0, 位置));
}
各释义.push(自定义词典.常用命名[所有词条[序号].] || 首选释义[序号]);
Expand All @@ -91,7 +89,11 @@ function 逐词翻译(选中文本, 所有词条, 所有词): string {
if (释义 !== "") {
各释义.push(释义);
}
释义 = 各释义.join("");
if (各释义.length > 1 && 各释义[0].indexOf("...") > 0) {
释义 = 各释义[0].replace("...", 各释义.splice(1).join(""))
} else {
释义 = 各释义.join("");
}
return 释义;
}

Expand Down
4 changes: 2 additions & 2 deletions test/查词.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ suite("查词测试", () => {
检查释义("gettingStarted", "启动");

// 将...替换为后续内容
检查释义("beforeRedesign", "在...之前重新设计");
检查释义("afterRedesignMobile", "在...之后重新设计移动的");
检查释义("beforeRedesign", "在重新设计之前");
检查释义("afterRedesignMobile", "在重新设计移动的之后");

// 优先查询短语
检查释义("lastName", "姓");
Expand Down

0 comments on commit 9b68a1a

Please sign in to comment.