目前文档里并没有详细介绍如何使用这个功能

1.申请reCAPTCHA

1.1打开网站reCAPTCHA

标题随便,选择V3

注意:网域为自己的一级域名(比如我有后台admin.a.com,我的前台www.a.com,这里就写a.com)

创建好后得到两个密钥

2.打开qexo的设置

2.1找到API设置,把第二个密钥填入并保存

3.打开你hexo的源代码

这里我安装async没有使用npm方法安装,而是下载下来源码,在thems文件夹,新建async文件夹,把源码丢进去的安装方式,这样子更容易自定义。

教程:

hexo-theme-async 安装方式(二)_哔哩哔哩_bilibili

3.1.1加入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
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
<article class="row trm-scroll-animation">
<div class="col-lg-12">
<h5 class="trm-title-with-divider">
友链申请
<span data-number="03"></span>
</h5>
</div>
<div class="col-lg-12">
<div class="trm-card">
<!-- 添加图片预览区域 -->
<div id="icon-preview" class="trm-icon-preview">
<div
class="qexo-frienddiv"
style="
border: 1px dashed var(--theme-color, #00283a);
box-shadow: none !important;
flex: 1 1 100% !important;
"
>
<div class="qexo-frienddivleft">
<img
class="qexo-myfriend"
src=""
alt="网站图标预览"
style="display: none"
/>
<div
class="qexo-default-icon"
style="
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
background-color: var(--card-bg-color-secondary);
border-radius: 12px;
border: 1px dashed var(--card-border-color);
"
>
<i
class="fas fa-image"
style="font-size: 24px; color: var(--text-secondary-color)"
></i>
</div>
</div>
<div class="qexo-frienddivright" style="text-align: left">
<span id="preview-name">您的站点名</span>
<br />
<div id="preview-des">站点描述</div>
</div>
</div>
</div>
<div class="field">
<!-- <label class="label trm-text-color">名称</label> -->
<div class="control has-icons-left">
<input
class="input trm-input"
type="text"
placeholder="您的站点名"
id="friend-name"
required
/>
<span class="icon is-small is-left trm-icon-color">
<i class="fas fa-signature"></i>
</span>
</div>
</div>
<div class="field">
<!-- <label class="label trm-text-color">链接</label> -->
<div class="control has-icons-left">
<input
class="input trm-input"
type="url"
placeholder="您网站首页的链接"
id="friend-link"
required
/>
<span class="icon is-small is-left trm-icon-color">
<i class="fas fa-link"></i>
</span>
</div>
<!-- <p class="help trm-text-secondary-color">请确保站点可访问!</p> -->
</div>
<div class="field">
<!-- <label class="label trm-text-color">图标</label> -->
<div class="control has-icons-left">
<input
class="input trm-input"
type="url"
placeholder="您的网站图标链接(尽量为正圆形)"
id="friend-icon"
required
/>
<span class="icon is-small is-left trm-icon-color">
<i class="fas fa-image"></i>
</span>
</div>
</div>
<div class="field">
<!-- <label class="label trm-text-color">描述</label> -->
<div class="control has-icons-left">
<input
class="input trm-input"
type="text"
placeholder="请用一句话介绍您的站点"
id="friend-des"
required
/>
<span class="icon is-small is-left trm-icon-color">
<i class="fas fa-info"></i>
</span>
</div>
</div>
<div class="field">
<div class="control text-center" style="margin-top: 40px">
<label class="cyberpunk-checkbox-label">
<input
type="checkbox"
id="friend-check"
class="cyberpunk-checkbox"
/>
我提交的不是无意义信息</label
>
<!-- <label class="checkbox trm-text-color">
<input type="checkbox" id="friend-check" class="trm-checkbox" />
我提交的不是无意义信息
</label> -->
</div>
</div>
<div class="field is-grouped">
<div class="control text-center">
<button
class="button trm-btn"
type="submit"
onclick="askFriend(event)"
>
申请友链
</button>
</div>
</div>
</div>
</div>
</article>

3.1.2加入js:

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
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<script src="https://recaptcha.net/recaptcha/api.js?render=你的第一个密钥"></script>
<script>
function TestUrl(url) {
var Expression = /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/;
var objExp = new RegExp(Expression);
if (objExp.test(url) != true) {
return false;
}
return true;
}
function showNotification(message, type = "info") {
const notification = document.createElement("div");
notification.className = `trm-notification trm-notification-${type}`;
notification.innerHTML = `
<div class="trm-notification-content">
<i class="fas ${
type === "error" ? "fa-exclamation-circle" : "fa-check-circle"
}"></i>
<span>${message}</span>
</div>
`;
document.body.appendChild(notification);
setTimeout(() => {
notification.classList.add("trm-notification-show");
}, 10);
setTimeout(() => {
notification.classList.remove("trm-notification-show");
setTimeout(() => {
notification.remove();
}, 300);
}, 3000);
}

function showLoading(message = "处理中...") {
const loading = document.createElement("div");
loading.className = "trm-loading";
loading.innerHTML = `
<div class="trm-loading-content">
<div class="trm-loading-spinner"></div>
<span>${message}</span>
</div>
`;
document.body.appendChild(loading);
return loading;
}

function askFriend(event) {
let check = $("#friend-check").is(":checked");
let name = $("#friend-name").val();
let url = $("#friend-link").val();
let image = $("#friend-icon").val();
let des = $("#friend-des").val();

if (!check) {
showNotification('请勾选"我提交的不是无意义信息"', "error");
return;
}
if (!(name && url && image && des)) {
showNotification("信息填写不完整!", "error");
return;
}
if (!TestUrl(url)) {
showNotification("URL格式错误! 需要包含HTTP协议头!", "error");
return;
}
if (!TestUrl(image)) {
showNotification("图片URL格式错误! 需要包含HTTP协议头!", "error");
return;
}

const loading = showLoading("正在提交申请...");
event.target.classList.add("is-loading");

grecaptcha.ready(function () {
grecaptcha
.execute("你的第一个密钥", {
action: "submit",
})
.then(function (token) {
$.ajax({
type: "get",
cache: false,
url: url,
dataType: "jsonp",
async: false,
processData: false,
timeout: 5000,
complete: function (data) {
if (data.status == 200) {
$.ajax({
type: "POST",
dataType: "json",
data: {
name: name,
url: url,
image: image,
description: des,
verify: token,
},
url: "https://你的qexo域名/pub/ask_friend/",
success: function (data) {
showNotification(data.msg, "success");
},
error: function () {
showNotification("提交失败,请稍后重试", "error");
},
});
} else {
let errorMsg = "URL无法连通! ";
if (data.status === 0) {
errorMsg += "可能原因:目标网站不支持跨域请求或网络连接失败";
} else if (data.status === 404) {
errorMsg += "目标页面不存在";
} else if (data.status === 403) {
errorMsg += "目标网站拒绝访问";
} else if (data.status === 500) {
errorMsg += "目标网站服务器错误";
} else if (data.status === 503) {
errorMsg += "目标网站暂时不可用";
} else {
errorMsg += "HTTP状态码: " + data.status;
}
showNotification(errorMsg, "error");
}
loading.remove();
event.target.classList.remove("is-loading");
},
});
});
});
}
</script>
<script src="https://registry.npmmirror.com/qexo-static/1.6.0/files/hexo/friends.js"></script>
<script>
function loadQexoFriends(id, url) {
var uri = url + "/pub/friends/";
var loadStyle =
'<div class="qexo_loading"><div class="qexo_part"><div style="display: flex; justify-content: center"><div class="qexo_loader"><div class="qexo_inner one"></div><div class="qexo_inner two"></div><div class="qexo_inner three"></div></div></div></div><p style="text-align: center; display: block">友链加载中...</p></div>';
document.getElementById(id).className = "qexo-friends";
document.getElementById(id).innerHTML = loadStyle;
var ajax;
try {
// Firefox, Opera 8.0+, Safari
ajax = new XMLHttpRequest();
} catch (e) {
// Internet Explorer
try {
ajax = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
ajax = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert("糟糕,你的浏览器不能上传文件!");
return false;
}
}
}
ajax.open("get", uri, true);
ajax.setRequestHeader("Content-Type", "text/plain");
ajax.onreadystatechange = function () {
if (ajax.readyState == 4) {
if (ajax.status == 200) {
var res = JSON.parse(ajax.response);
if (res["status"]) {
var friends = res["data"];
document.getElementById(id).innerHTML = "";
for (let i = 0; i < friends.length; i++) {
document.getElementById(id).innerHTML +=
'<p><a target="_blank" href="' +
friends[i]["url"] +
'" title="' +
friends[i]["name"] +
'" class="qexo-friendurl"></p><div class="qexo-frienddiv"><div class="qexo-frienddivleft"><img class="qexo-myfriend" src="' +
friends[i]["image"] +
'"></div><div class="qexo-frienddivright"><span style="font-weight: bold;">' +
friends[i]["name"] +
"</span><br>" +
friends[i]["description"] +
"</div></div></a>";
}
} else {
console.log(res["data"]["msg"]);
}
} else {
console.log("友链获取失败! 网络错误");
}
}
};
ajax.send(null);
}
const iconInput = document.getElementById("friend-icon");
const nameInput = document.getElementById("friend-name");
const desInput = document.getElementById("friend-des");
const previewImg = document.querySelector(".qexo-myfriend");
const previewName = document.querySelector("#preview-name");
const previewDes = document.querySelector("#preview-des");

function updatePreview() {
if (iconInput.value) {
previewImg.src = iconInput.value;
previewImg.style.display = "block";
document.querySelector(".qexo-default-icon").style.display = "none";
} else {
previewImg.style.display = "none";
document.querySelector(".qexo-default-icon").style.display = "flex";
}
previewName.textContent = nameInput.value || "您的站点名";
previewDes.textContent = desInput.value || "站点描述";
}

iconInput.addEventListener("input", updatePreview);
nameInput.addEventListener("input", updatePreview);
desInput.addEventListener("input", updatePreview);
</script>

⚠️注意 !!!:

在上面js中的

要填入自己的第一个密钥

再在上面js中的grecaptcha填入自己的第一个密钥

grecaptcha中的

url: "https://你的qexo域名/pub/ask_friend/",

修改为自己的qexo域名

3.1.3加入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
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
<style>
/* From Uiverse.io by adamgiebl */
.cyberpunk-checkbox {
appearance: none;
width: 20px;
height: 20px;
border: 2px solid #5a5df0;
border-radius: 5px;
background-color: transparent;
display: inline-block;
position: relative;
margin-right: 10px;
cursor: pointer;
}

.cyberpunk-checkbox:before {
content: "";
background-color: #5a5df0;
display: block;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%) scale(0);
width: 10px;
height: 10px;
border-radius: 3px;
transition: all 0.3s ease-in-out;
}

.cyberpunk-checkbox:checked:before {
transform: translate(-50%, -50%) scale(1);
}

.cyberpunk-checkbox-label {
font-size: 0.95rem;
color: var(--theme-color, #00283a);
justify-content: center;
cursor: pointer;
user-select: none;
display: flex;
align-items: center;
}
/*remove recaptcha logo*/
.grecaptcha-badge {
visibility: hidden;
}
.grecaptcha-badge {
display: none;
}
/* 友情链接申请表单样式 */
.field {
margin-bottom: 1.5rem;
}

.control {
height: auto;
margin-top: 0.5rem;
}

.trm-input {
padding: 0.75rem 1rem;
font-size: 0.95rem;
line-height: 1.5;
transition: all 0.3s ease;
width: 100%;
}

.trm-input:focus {
outline: none;
border-color: transparent;
box-shadow: none;
}

.label {
font-size: 0.95rem;
font-weight: 500;
color: var(--text-color);
margin-bottom: 0.25rem;
}

.help {
margin-top: 0.5rem;
font-size: 0.85rem;
color: var(--text-secondary-color);
}

.has-icons-left .icon {
width: 10px;
position: absolute;
left: 1rem;
top: 50%;
transform: translateY(-50%);
pointer-events: none;
color: var(--theme-color);
transition: color 0.3s ease;
display: flex;
justify-content: center;
}

.has-icons-left .trm-input {
padding-left: 3rem;
}

/* 调整输入框高度 */
.control {
position: relative;
height: 48px;
}

.trm-input {
height: 100%;
padding: 0 1rem 0 3rem;
}
.has-icons-left .icon.is-left {
left: 0.75rem;
}

/* 移动端适配 */
@media (max-width: 768px) {
.field {
margin-bottom: 1.25rem;
}

.trm-input {
padding: 0.65rem 0.9rem;
font-size: 0.9rem;
}

.label {
font-size: 0.9rem;
}

.help {
font-size: 0.8rem;
}

.has-icons-left .icon {
left: 0.75rem;
}

.has-icons-left .trm-input {
padding-left: 2.5rem;
}

.has-icons-left .icon.is-left {
left: 0.5rem;
display: flex;
justify-content: center;
}
.form-ask-friend {
padding: 1rem;
}

.field {
margin-bottom: 1rem;
}

.trm-input {
font-size: 0.9rem;
}

.trm-btn {
width: 100%;
}
}
.control {
height: 40px;
}
.button {
background-color: var(--theme-bg-color, #fcfcfe);
color: var(--theme-color, #00283a);
box-shadow: var(--box-shadow);
}
.message-body {
background-color: #00283a;
border-radius: var(--card-border-radius);
padding: var(--card-padding);
box-sizing: border-box;
margin-bottom: var(--card-bottom-card);
}
.form-ask-friend {
padding: 2rem;
background-color: var(--card-bg-color);
border-radius: var(--card-border-radius);
box-shadow: var(--card-box-shadow);
transition: all 0.3s ease;
}

.trm-input {
background-color: var(--card-bg-color-secondary);
border: 1px solid var(--card-border-color);
color: var(--text-color);
border-radius: var(--card-border-radius);
transition: all 0.3s ease;
}

.trm-input:focus {
border-color: var(--primary-color);
box-shadow: 0 0 0 0.125em var(--primary-weak);
}

.trm-checkbox {
margin-right: 0.5em;
color: var(--theme-color, #00283a);
}

.trm-btn {
border-radius: var(--card-border-radius);
font-weight: 500;
transition: all 0.3s ease;
}

.trm-btn-primary:hover {
background-color: var(--primary-hover-color);
}
/* 通知样式 */
.trm-notification {
position: fixed;
bottom: 20px;
right: 20px;
background-color: var(--card-bg-color);
color: var(--text-color);
padding: 15px 25px;
border-radius: var(--card-border-radius);
box-shadow: var(--card-box-shadow);
transform: translateX(100%);
transition: transform 0.3s ease;
z-index: 9999;
}

.trm-notification-show {
transform: translateX(0);
}

.trm-notification-content {
display: flex;
align-items: center;
}

.trm-notification-content i {
margin-right: 10px;
}

.trm-notification-success {
background-color: #d1e7dd;
color: #0f5132;
}

.trm-notification-error {
background-color: #f8d7da;
color: #842029;
}

.trm-notification-info {
background-color: #cff4fc;
color: #055160;
}

/* 加载动画样式 */
.trm-loading {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
z-index: 9999;
}

.trm-loading-content {
background-color: var(--card-bg-color);
padding: 20px 30px;
border-radius: var(--card-border-radius);
display: flex;
flex-direction: column;
align-items: center;
}

.trm-loading-spinner {
width: 40px;
height: 40px;
border: 4px solid var(--theme-color);
border-top-color: transparent;
border-radius: 50%;
animation: trm-spin 1s linear infinite;
margin-bottom: 10px;
}

@keyframes trm-spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
/* 添加默认图标样式 */
.trm-icon-placeholder {
display: flex;
justify-content: center;
align-items: center;
width: 80px;
height: 80px;
margin: 0 auto;
background-color: var(--card-bg-color-secondary);
border-radius: 50%;
color: var(--text-secondary-color);
font-size: 24px;
border: 2px dashed var(--card-border-color);
}

.trm-icon-preview {
text-align: center;
padding: 10px;
background-color: var(--card-bg-color-secondary);
border-radius: var(--card-border-radius);
/* margin-top: 10px; */
margin-bottom: 40px !important;
min-height: 100px;
display: flex;
align-items: center;
justify-content: center;
}

.trm-icon-preview img {
transition: all 0.3s ease;
}

.trm-icon-preview img:hover {
transform: scale(1.1);
}
/* 统一友情链接样式 */
#qexo-friends {
width: 100%;
display: flex;
flex-wrap: wrap;
gap: 20px;
margin-bottom: var(--card-bottom-card);
padding: 0 20px;
}

.qexo-frienddiv {
margin-bottom: 0;
padding: 20px;
background-color: var(--theme-bg-color) !important;
border-radius: var(--card-border-radius) !important;
box-shadow: var(--box-shadow);
transition: all 0.3s ease;
display: flex;
align-items: center;
flex: 1 1 calc(50% - 10px); /* 默认显示两个 */
box-sizing: border-box;
background-color: #00283a;
transform: translateY(0);
will-change: transform;
}

/* 移动端样式 */
@media (max-width: 820px) {
.qexo-frienddiv {
flex: 1 1 100%; /* 移动端时占满整行 */
/* padding-bottom:0px !important; */
margin-bottom: 10px; /* 添加间距 */
}
.qexo-frienddiv.col-lg-6 {
width: 100% !important;
max-width: 100% !important;
background-color: var(--theme-bg-color, #fcfcfe);
color: var(--theme-color, #00283a);
box-shadow: var(--box-shadow);
}
#qexo-friends {
width: 100%;
display: flex;
flex-wrap: wrap;
gap: 0px !important;
/* margin-bottom: 40px; */
padding: 0 20px;
margin-bottom: 0px !important;
}
}
/* 添加与trm-link-box一致的hover效果 */
.qexo-frienddiv:hover {
transform: translateY(-5px);
box-shadow: var(--card-hover-box-shadow);
background-color: var(--theme-bg-color, #fcfcfe);
color: var(--theme-color, #00283a);
box-shadow: var(--box-shadow);
}

.qexo-frienddivleft {
width: 80px;
height: 80px;
margin-right: 20px;
flex-shrink: 0;
background-color: var(--card-bg-color-secondary); /* 添加背景颜色 */
padding: 5px; /* 添加内边距 */
border-radius: 12px; /* 保持圆角一致 */
transition: all 0.3s ease; /* 添加过渡效果 */
}

.qexo-frienddiv:hover .qexo-frienddivleft {
transform: scale(1.05); /* 添加图标缩放效果 */
}
/* 当只有一个友情链接时 */
.qexo-frienddiv:only-child {
max-width: 100% !important;
flex: 1 1 100%;
}

/* 添加col-lg-6样式 */
.qexo-frienddiv.col-lg-6 {
width: 50%;
max-width: 50%;
}

.qexo-frienddiv:hover {
transform: translateY(-5px);
box-shadow: var(--card-hover-box-shadow);
}

.qexo-frienddivleft {
width: 80px;
height: 80px;
margin-right: 20px;
flex-shrink: 0;
background-color: var(--card-bg-color-secondary); /* 添加背景颜色 */
padding: 5px; /* 添加内边距 */
border-radius: 12px; /* 保持圆角一致 */
}

.qexo-myfriend {
width: 100%;
height: 100%;
border-radius: 12px;
object-fit: cover;
}

.qexo-frienddivright {
flex: 1;
}

.qexo-frienddivright span {
font-size: 1.1rem;
color: var(--theme-color, #00283a);
font-weight: bold;
display: block;
/* margin-bottom: 8px; */
}
.qexo-frienddivright a {
font-size: 0.9rem;
}
.qexo-frienddivright a span {
font-size: 1.1rem;
color: var(--theme-color, #00283a);
text-decoration: none;
}

.qexo-frienddivright a:hover {
color: var(--primary-color);
}

.qexo-frienddivright div {
font-size: 0.9rem;
color: var(--text-secondary-color);
line-height: 1.5;
}
</style>

4.大功告成

之后你收到申请后,qexo右上角就会显示,

注意:这个是要上线才能显示,毕竟你配置reCAPTCHA时候,域名没有包括localhost