# 前言

最近有很多博主给自己博客文章添加了文章总结,我找了一下 hexo 相关资料,结果均是调用第三方 API。

第三方 API 好处有很多:方便,快捷,省心,但也有很多缺点:稳定性,内容私密性,内容审计不可控。

例如担心文章私密性的友友可以本地部署 ChatGLM 之类的模型进行离线总结,并且内容永远存在于文章中,不会受第三方 API 影响,同时也可以对生成的内容进行审计修改,甚至你还可以自行总结,高度自定义,完全不受约束。

这里我们使用 TianliGPT 的样式并对 JavaScript 部分进行魔改,不使用它的 API。

TianliGPT 项目地址:https://github.com/zhheo/Post-Abstract-AI

TianliGPT LICENSE: 禁止用于其他项目的商业用途,仅限TianLIGPT使用。允许个人用途的修改和优化。

# 正文

首先是最核心的文章总结,因为没有使用 TianliGPT 的 API,所以需要自行寻找合适 GPT 进行手动总结,推荐 ChatGPT文章总结助手 这个浏览器插件,填写你的 API 和 Key 即可对页面进行总结。

然后我们使用 TianliGPT 的样式,这里可以去项目仓库自行下载调整也可以使用我下发贴出的 css:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
:root {
--heo-white: #fff;
--heo-white-op: rgba(255, 255, 255, 0.2);
--heo-black: #000;
--heo-black-op: rgba(0, 0, 0, 0.2);
--heo-none: #00000000;
--heo-gray: #999999;
--heo-gray-op: #9999992b;
--heo-vip: #e5a80d;
--heo-main: var(--heo-theme);
--heo-main-op: var(--heo-theme-op);
--heo-main-op-deep: var(--heo-theme-op-deep);
--heo-main-none: var(--heo-theme-none);
--heo-shadow-theme: 0 8px 12px -3px var(--heo-theme-op);
--heo-shadow-blackdeep: 0 2px 16px -3px rgba(0, 0, 0, .15);
--heo-shadow-main: 0 8px 12px -3px var(--heo-main-op);
--heo-shadow-blue: 0 8px 12px -3px rgba(40, 109, 234, .20);
--heo-shadow-white: 0 8px 12px -3px rgba(255, 255, 255, .20);
--heo-shadow-black: 0 0 12px 4px rgba(0, 0, 0, .05);
--heo-shadow-yellow: 0px 38px 77px -26px rgba(255, 201, 62, .12);
--heo-shadow-red: 0 8px 12px -3px #ee7d7936;
--heo-shadow-green: 0 8px 12px -3px #87ee7936;
--heo-logo-color: linear-gradient(215deg, #4584ff 0%, #cf0db9 100%);
--heo-snackbar-time: 5s;
--heo-theme: #425AEF;
--heo-theme-op: #4259ef23;
--heo-theme-op-deep: #4259efdd;
--heo-theme-none: #4259ef01;
--heo-blue: #425AEF;
--heo-red: #f04a63;
--heo-pink: #FF7C7C;
--heo-green: #57bd6a;
--heo-yellow: #c28b00;
--heo-yellow-op: #d99c001a;
--heo-orange: #e38100;
--heo-fontcolor: #363636;
--heo-background: #f7f9fe;
--heo-reverse: #000;
--heo-maskbg: rgba(255, 255, 255, 0.6);
--heo-maskbgdeep: rgba(255, 255, 255, 0.85);
--heo-hovertext: var(--heo-main);
--heo-ahoverbg: #F7F7FA;
--heo-lighttext: var(--heo-main);
--heo-secondtext: rgba(60, 60, 67, 0.8);
--heo-scrollbar: rgba(60, 60, 67, 0.4);
--heo-card-btn-bg: #edf0f7;
--heo-post-blockquote-bg: #fafcff;
--heo-post-tabs-bg: #f2f5f8;
--heo-secondbg: #f1f3f8;
--heo-shadow-nav: 0 5px 12px -5px rgba(102, 68, 68, 0.05);
--heo-card-bg: #fff;
--heo-card-bg-op: var(--heo-black-op);
--heo-card-bg-none: rgba(255, 255, 255, 0);
--heo-shadow-lightblack: 0 5px 12px -5px rgba(102, 68, 68, 0.00);
--heo-shadow-light2black: 0 5px 12px -5px rgba(102, 68, 68, 0.00);
--heo-card-border: #e3e8f7;
--heo-shadow-border: 0 8px 16px -4px #2c2d300c;
--style-border: 1px solid var(--heo-card-border);
--style-border-always: 1px solid var(--heo-card-border);
--style-border-hover: 1px solid var(--heo-main);
--style-border-hover-always: 1px solid var(--heo-main);
--style-border-dashed: 1px dashed var(--heo-theme-op);
--style-border-forever: 2px solid var(--heo-main)
}

[data-theme=light] {
--heo-theme: #425AEF;
--heo-theme-op: #4259ef23;
--heo-theme-op-deep: #4259efdd;
--heo-theme-none: #4259ef01;
--heo-blue: #425AEF;
--heo-red: #f04a63;
--heo-pink: #FF7C7C;
--heo-green: #57bd6a;
--heo-yellow: #c28b00;
--heo-yellow-op: #d99c001a;
--heo-orange: #e38100;
--heo-fontcolor: #363636;
--heo-background: #f7f9fe;
--heo-reverse: #000;
--heo-maskbg: rgba(255, 255, 255, 0.6);
--heo-maskbgdeep: rgba(255, 255, 255, 0.85);
--heo-hovertext: var(--heo-main);
--heo-ahoverbg: #F7F7FA;
--heo-lighttext: var(--heo-main);
--heo-secondtext: rgba(60, 60, 67, 0.8);
--heo-scrollbar: rgba(60, 60, 67, 0.4);
--heo-card-btn-bg: #edf0f7;
--heo-post-blockquote-bg: #fafcff;
--heo-post-tabs-bg: #f2f5f8;
--heo-secondbg: #f1f3f8;
--heo-shadow-nav: 0 5px 12px -5px rgba(102, 68, 68, 0.05);
--heo-card-bg: #fff;
--heo-card-bg-op: var(--heo-black-op);
--heo-card-bg-none: rgba(255, 255, 255, 0);
--heo-shadow-lightblack: 0 5px 12px -5px rgba(102, 68, 68, 0.00);
--heo-shadow-light2black: 0 5px 12px -5px rgba(102, 68, 68, 0.00);
--heo-card-border: #e3e8f7;
--heo-shadow-border: 0 8px 16px -4px #2c2d300c;
--style-border: 1px solid var(--heo-card-border);
--style-border-always: 1px solid var(--heo-card-border);
--style-border-hover: 1px solid var(--heo-main);
--style-border-hover-always: 1px solid var(--heo-main);
--style-border-dashed: 1px dashed var(--heo-theme-op);
--style-border-forever: 2px solid var(--heo-main)
}

[data-theme=dark],
body.dark,
body.dark-theme {
--heo-theme: #f2b94b;
--heo-theme-op: #f2b94b23;
--heo-theme-op-deep: #f2b94bdd;
--heo-theme-none: #f2b94b00;
--heo-blue: #0084FF;
--heo-red: #FF3842;
--heo-pink: #d44040;
--heo-green: #3e9f50;
--heo-yellow: #ffc93e;
--heo-yellow-op: #ffc93e30;
--heo-orange: #ff953e;
--heo-fontcolor: #F7F7FA;
--heo-background: #18171d;
--heo-reverse: #fff;
--heo-maskbg: rgba(0, 0, 0, 0.6);
--heo-maskbgdeep: rgba(0, 0, 0, 0.85);
--heo-hovertext: #0A84FF;
--heo-ahoverbg: #fff;
--heo-lighttext: var(--heo-theme);
--heo-secondtext: #a1a2b8;
--heo-scrollbar: rgba(200, 200, 223, 0.4);
--heo-card-btn-bg: #30343f;
--heo-post-blockquote-bg: #000;
--heo-post-tabs-bg: #121212;
--heo-secondbg: #30343f;
--heo-shadow-nav: 0 5px 20px 0px rgba(28, 28, 28, 0.4);
--heo-card-bg: #1d1e22;
--heo-card-bg-op: var(--heo-white-op);
--heo-card-bg-none: #1d1b2600;
--heo-shadow-lightblack: 0 5px 12px -5px rgba(102, 68, 68, 0.0);
--heo-shadow-light2black: 0 5px 12px -5px rgba(102, 68, 68, 0.0);
--heo-card-border: #3d3d3f;
--heo-shadow-border: 0 8px 16px -4px #00000050;
--style-border: 1px solid var(--heo-card-border);
--style-border-always: 1px solid var(--heo-card-border);
--style-border-hover: 1px solid var(--heo-theme);
--style-border-hover-always: 1px solid var(--heo-theme);
--style-border-dashed: 1px dashed var(--heo-theme-op);
--style-border-forever: 2px solid var(--heo-lighttext)
}

.post-ai {
background: var(--heo-secondbg);
border-radius: 12px;
padding: 12px;
line-height: 1.3;
border: var(--style-border-always);
margin: 16px 0
}

@media screen and (max-width:768px) {
.post-ai {
margin-top: 22px
}
}

.ai-title {
display: flex;
color: var(--heo-lighttext);
border-radius: 8px;
align-items: center;
padding: 0 12px;
cursor: default;
user-select: none;
position: relative
}

.ai-title-text {
font-weight: 700;
margin-left: 8px;
line-height: 1
}

.ai-explanation {
margin-top: 12px;
padding: 8px 12px;
background: var(--heo-card-bg);
border-radius: 8px;
border: var(--style-border-always);
font-size: 15px;
line-height: 1.4;
display: flex
}

.ai-suggestions {
display: flex;
flex-wrap: wrap
}

.ai-suggestions .ai-suggestions-item {
margin-top: 12px;
padding: 8px 12px;
background: var(--heo-card-bg);
border-radius: 8px 8px 8px 0;
border: var(--style-border-always);
font-size: 15px;
line-height: 1.4;
display: flex;
width: fit-content;
margin-right: 12px;
cursor: pointer;
transition: .3s
}

.ai-suggestions .ai-suggestions-item:hover {
background: var(--heo-main);
color: var(--heo-white)
}

.blinking-cursor {
background-color: var(--heo-main);
width: 10px;
height: 16px;
display: inline-block;
vertical-align: middle;
animation: blinking-cursor .5s infinite;
-webkit-animation: blinking-cursor .5s infinite;
margin-left: 4px
}

.ai-tips {
font-size: 12px;
color: var(--heo-secondtext);
margin-right: auto;
}

.ai-bottom {
width: 100%;
margin-top: 12px;
padding: 0 12px;
display: flex;
}

@keyframes blinking-cursor {
0% {
opacity: 1
}

40% {
opacity: 1
}

50% {
opacity: 0
}

90% {
opacity: 0
}

100% {
opacity: 1
}
}

.ai-tag {
font-size: 12px;
background-color: var(--heo-lighttext);
color: var(--heo-card-bg);
font-weight: 700;
border-radius: 4px;
margin-left: auto;
line-height: 1;
padding: 4px;
display: flex;
align-items: center;
justify-content: center;
transition: all .3s, background-color 0s;
position: absolute;
right: 12px
}

i.fa-solid.fa-robot {
width: 24px;
height: 24px;
display: flex;
background: var(--heo-lighttext);
color: var(--heo-card-bg);
font-size: 14px;
border-radius: 20px;
justify-content: center;
align-items: center
}

ins.adsbygoogle {
margin: 16px 0;
background: var(--heo-card-bg);
border-radius: 12px;
overflow: hidden;
border: var(--style-border-always)
}

#ai-Toggle {
font-size: 12px;
background: var(--heo-lighttext);
color: var(--heo-card-bg);
padding: 4px;
border-radius: 4px;
margin-left: 6px;
transform: scale(.8);
cursor: pointer;
transition: .3s;
font-weight: 700
}

#ai-Toggle:hover {
background: var(--heo-fontcolor);
color: var(--heo-card-bg)
}

.ai-title-icon {
width: 20px;
height: 20px
}

.ai-title-icon svg {
width: 20px;
height: 20px;
fill: var(--heo-main)
}

.ai-title-icon svg path {
fill: var(--heo-main)
}

.ai-tag svg {
fill: #7e8a97
}

@keyframes breathe {
0% {
-webkit-transform: scale(.97);
-moz-transform: scale(.97);
-o-transform: scale(.97);
-ms-transform: scale(.97);
transform: scale(.97)
}

50% {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-o-transform: scale(1.1);
-ms-transform: scale(1.1);
transform: scale(1.1)
}

100% {
-webkit-transform: scale(.97);
-moz-transform: scale(.97);
-o-transform: scale(.97);
-ms-transform: scale(.97);
transform: scale(.97)
}
}

.ai-tag.playing svg {
animation: .5s linear 0s infinite normal none running breathe;
transform-origin: center;
width: 20px;
height: 20px
}

将 css 保存并引用在 <head> 中。

1
<link rel="stylesheet" href="/css/tianli_gpt.css">

接着我们在需要展示文章总结的地方插入 HTML:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<div class="post-ai">
<div class="ai-title">
<i class="fa-solid fa-robot"></i>
<a class="ai-title-left" data-pjax-state="">
<div class="ai-title-text">文章摘要</div>
<div class="ai-link"><i class="heofont icon-arrow-right-s-line"></i></div>
</a>
<div class="ai-tag" id="ai-tag">GoodBoyboyGPT</div>
</div>
<div class="ai-explanation" style="display: block;">
<span class="ai-typed-text"></span>
<div class="ai-source-text">
<span>填写总结内容的地方。</span>
</div>
</div>
<div class="ai-suggestions"></div>
<div class="ai-bottom">
<div class="ai-tips">此内容根据文章生成,并经过人工审核,仅用于文章内容的解释与总结</div>
</div>
</div>
<script defer>
function checkTyped() {
if (typeof Typed !== 'undefined') {
var typed = new Typed('.ai-typed-text', {stringsElement: '.ai-source-text',typeSpeed: 25,startDelay:1000,fadeOut:false,});
} else {
setTimeout(checkTyped, 100);
}
}
checkTyped();
</script>

如果开启了 pjax 无刷则使用下面 HTML,否则可能会导致没有打字机效果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<div class="post-ai">
<div class="ai-title">
<i class="fa-solid fa-robot"></i>
<a class="ai-title-left" data-pjax-state="">
<div class="ai-title-text">文章摘要</div>
<div class="ai-link"><i class="heofont icon-arrow-right-s-line"></i></div>
</a>
<div class="ai-tag" id="ai-tag">GoodBoyboyGPT</div>
</div>
<div class="ai-explanation" style="display: block;">
<span class="ai-typed-text"></span>
<div class="ai-source-text">
<span>填写总结内容的地方。</span>
</div>
</div>
<div class="ai-suggestions"></div>
<div class="ai-bottom">
<div class="ai-tips">此内容根据文章生成,并经过人工审核,仅用于文章内容的解释与总结</div>
</div>
</div>
<script data-pjax defer>
function checkTyped() {
if (typeof Typed !== 'undefined') {
var typed = new Typed('.ai-typed-text', {stringsElement: '.ai-source-text',typeSpeed: 25,startDelay:1000,fadeOut:false,});
} else {
setTimeout(checkTyped, 100);
}
}
checkTyped();
</script>

这里我们使用到了一个第三方 js:typed

因此我们还需要引入 typed

<foot> 标签里引用 typed

1
2
<script type="text/javascript" src="https://jsdelivr.goodboyboy.top/npm/typed.js@2.0.16/dist/typed.umd.js"></script>
<!-- 上方链接地址可以将文件下载至本地后自行更改 -->

# 效果

最终效果如本篇文章最上面的文章总结。