From 4b475abc6f8d5285dc38555789f9ab6699520ac8 Mon Sep 17 00:00:00 2001
From: "1152958806@qq.com" <1152958806@qq.com>
Date: Fri, 11 Aug 2023 00:19:48 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96AI-=E6=91=98=E8=A6=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
templates/assets/libs/gpt/post-ai.js | 52 ++++++++++++++++------------
templates/post.html | 2 +-
2 files changed, 31 insertions(+), 23 deletions(-)
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 += ``;
+ if(thumbnail.length>0){
+ thumbnail.forEach(item => {
+ if (item) {
+ if(!title.includes(item.title)){
+ index +=1;
+ list += ``;
+ }
+ }
+ });
}
-
return `很抱歉,无法找到类似的文章,你也可以看看本站最新发布的文章:
${list}
`;
}
-
- let list = '';
- for (let i = 0; i < thumbnail.length; i++) {
- const item = thumbnail[i];
- list += ``;
- }
-
+ thumbnail.forEach(item => {
+ if (item) {
+ if(!title.includes(item.title)){
+ index +=1;
+ list += ``;
+ }
+ }
+ });
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 @@