fix bug 545

Bug545-HuangHuiLing
1994836463@qq.com 2024-04-16 19:08:42 +08:00
parent 5ad6ba07cf
commit 0b5dacb472
1 changed files with 3 additions and 3 deletions

View File

@ -34,10 +34,10 @@ function highLight() {
} }
const list = allWords.split(" ");//将所有的生词放入一个list中用于后续处理 const list = allWords.split(" ");//将所有的生词放入一个list中用于后续处理
//判断获取的单词不能为空 //判断获取的单词不能为空
if(word !== null && word !== "" && word !== " "){ if(word != null && word != "" && word != " "){
let articleContent_fb2 = articleContent; let articleContent_fb2 = articleContent;
if(localStorage.getItem("nowWord").indexOf(word) !== -1){ if(localStorage.getItem("nowWord").indexOf(word) != -1){
while(articleContent_fb2.toLowerCase().indexOf(word.toLowerCase()) !== -1){ while(articleContent_fb2.toLowerCase().indexOf(word.toLowerCase()) != -1){
// 找到副本中和list[i]匹配的第一个单词(第一种匹配情况),并赋值给list[i]。 // 找到副本中和list[i]匹配的第一个单词(第一种匹配情况),并赋值给list[i]。
const index = articleContent_fb2.toLowerCase().indexOf(word.toLowerCase()); const index = articleContent_fb2.toLowerCase().indexOf(word.toLowerCase());
word = articleContent_fb2.substring(index, index + word.length); word = articleContent_fb2.substring(index, index + word.length);