diff --git a/templates/assets/libs/gpt/post-ai.js b/templates/assets/libs/gpt/post-ai.js index 5d8d9e93..480fb996 100644 --- a/templates/assets/libs/gpt/post-ai.js +++ b/templates/assets/libs/gpt/post-ai.js @@ -29,20 +29,20 @@ function HaoPostAI(AI_option) { post_ai_box.className = 'post-ai'; post.insertBefore(post_ai_box, post.firstChild); - var PostAI = ` + var PostAI = `
${interface.name}
` - if(switchBtn){ - PostAI = PostAI+ `
${interface.aiToggle}
`; + if (switchBtn) { + PostAI += `
${interface.aiToggle}
`; } - PostAI = PostAI+ ` `; - if(modeName == 'local'){ - PostAI = PostAI+ `
${gptName} GPT
`; - }else{ - PostAI = PostAI+ `
${interface.version}
`; + PostAI += ` `; + if (modeName == 'local') { + PostAI += `
${gptName} GPT
`; + } else { + PostAI += `
${interface.version}
`; } - PostAI = PostAI+ ` + PostAI += `
AI初始化中...
@@ -53,7 +53,7 @@ function HaoPostAI(AI_option) {
前往tianli博客
`; - post_ai_box.innerHTML =PostAI; + post_ai_box.innerHTML = PostAI; // 当前随机到的ai摘要到index let lastAiRandomIndex = -1; let animationRunning = true; // 标志变量,控制动画函数的运行 @@ -263,27 +263,35 @@ function HaoPostAI(AI_option) { function recommendList() { let thumbnail = document.querySelectorAll('.relatedPosts-list a'); + var title = document.title; + let list = ''; + let index = 0; if (!thumbnail.length) { const cardRecentPost = document.querySelector('.card-widget.card-recent-post'); if (!cardRecentPost) return ''; thumbnail = cardRecentPost.querySelectorAll('.aside-list-item a'); - let list = ''; - for (let i = 0; i < thumbnail.length; i++) { - const item = thumbnail[i]; - list += `
${i + 1}:${item.title}
`; + if(thumbnail.length>0){ + thumbnail.forEach(item => { + if (item) { + if(!title.includes(item.title)){ + index +=1; + list += `
${i + 1}:${item.title}
`; + } + } + }); } - return `很抱歉,无法找到类似的文章,你也可以看看本站最新发布的文章:
${list}
`; } - - let list = ''; - for (let i = 0; i < thumbnail.length; i++) { - const item = thumbnail[i]; - list += `
推荐${i + 1}:${item.title}
`; - } - + thumbnail.forEach(item => { + if (item) { + if(!title.includes(item.title)){ + index +=1; + list += `
推荐${index}:${item.title}
`; + } + } + }); return `推荐文章:
${list}
`; } diff --git a/templates/post.html b/templates/post.html index ad655373..8f7e6cbf 100644 --- a/templates/post.html +++ b/templates/post.html @@ -151,7 +151,7 @@