插件的json模式的json变量名就是当你输入返回格式是json的时候提取文字的那个变量
例如访问https://api.qster.top/API/v1/chat/?type=json&msg=
返回格式是{
"code": 400, "problem": "", "answer": "请给出一个问题"
}
那么answer这个是我们需要的内容
你就可以把返回的变量里有文字的这个变量名填上去就可以了
首先下载插件到usr/plugins/目录进行解压(文件名必须是 AISummary 不然会报错)
然后在后台启用AISummary插件
接着把AI.php上传到主题的任意一个位置当然你要知道路径 等会要用(Joe再续前缘版可以上传到usr/themes/Joe/module/目录)
<div class="title-theme">AI摘要</div>
<div class="joe_header__slideout-menu panel-b">
<?php if ($this->fields->content) :?>
<div class="ai-summary-block">
<p>AI 摘要:<span class="typing-effect"><?php echo $this->fields->content;?></span></p>
</div>
<?php endif;?>
<style>
.ai-summary-block {
background-color: #f5f5f5;
padding: 15px;
border: 1px solid #ddd;
border-radius: 5px;
margin-bottom: 20px;
}
.typing-effect {
white-space: nowrap;
overflow: hidden;
animation: typing 2s steps(40) forwards;
}
@keyframes typing {
from {
width: 0;
}
to {
width: 100%;
}
}
.joe_header__slideout-menu.panel-b {
overflow-y: scroll;
}
h2 {
text-align: center;
}
h3 {
color: black;
font-size: smaller;
text-align: center;
}
</style>
<script>
document.addEventListener('DOMContentLoaded', function () {
const typingElements = document.querySelectorAll('.typing-effect');
typingElements.forEach(element => {
element.classList.remove('typing-effect');
const text = element.textContent;
element.textContent = '';
let i = 0;
const typingInterval = setInterval(() => {
if (i < text.length) {
element.textContent += text[i];
i++;
} else {
clearInterval(typingInterval);
}
}, 50);
});
});
</script>
</div>
<br>
{/collapse-item}
{collapse-item label="通用AI.php代码"}
<div class="title-theme">AI摘要</div>
<div class="joe_header__slideout-menu panel-b">
<?php if ($this->fields->content) :?>
<div class="ai-summary-block">
<p>AI 摘要:<span class="typing-effect"><?php echo $this->fields->content;?></span></p>
</div>
<?php endif;?>
<style>
.title-theme {
position: relative;
padding-left: 1.2em;
font-size: 15px;
color: var(--main-color);
}
.title-theme small {
font-size: 80%;
opacity: .7
}
.title-theme:before {
position: absolute;
content: '';
width: 4px;
background: var(--theme);
top: 10%;
left: 2px;
bottom: 10%;
border-radius: 5px;
box-shadow: 1px 1px 3px -1px var(--theme)
}
.ai-summary-block {
background-color: #f5f5f5;
padding: 15px;
border: 1px solid #ddd;
border-radius: 5px;
margin-bottom: 20px;
}
.typing-effect {
white-space: nowrap;
overflow: hidden;
animation: typing 2s steps(40) forwards;
}
@keyframes typing {
from {
width: 0;
}
to {
width: 100%;
}
}
.joe_header__slideout-menu.panel-b {
overflow-y: scroll;
}
h2 {
text-align: center;
}
h3 {
color: black;
font-size: smaller;
text-align: center;
}
</style>
<script>
document.addEventListener('DOMContentLoaded', function () {
const typingElements = document.querySelectorAll('.typing-effect');
typingElements.forEach(element => {
element.classList.remove('typing-effect');
const text = element.textContent;
element.textContent = '';
let i = 0;
const typingInterval = setInterval(() => {
if (i < text.length) {
element.textContent += text[i];
i++;
} else {
clearInterval(typingInterval);
}
}, 50);
});
});
</script>
</div>
<br>
{/collapse-item}
然后在主题的post.php里面合适的位置添加以下代码
<?php $this->need('module/AI.php'); ?>
Joe再续前缘版本可以添加在post.php的第120行下面第121行