前言

起初是看到heo佬做的控制面板,扒过来之后想起右下角有悬浮按钮,应该可以整合到一起,结果弄着弄着,直接就将右下角的按钮弄成一个面板了,这个就叫设置面板,控制面板就被设置面板代替了。

预览

效果如下图:

修改pug模板

添加设置面板,找到themes\butterfly\layout\includes\rightside.pug文件,因为修改的东西过多,直接将下面的代码覆盖全文即可:

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
- const { readmode, translate, darkmode, aside, chat_btn } = theme
mixin rightsideItem(array)
each item in array
case item
when 'readmode'
if is_post() && readmode
button#readmode(type="button" title=_p('rightside.readmode_title'))
i.fas.fa-book-open
when 'translate'
if translate.enable
button#translateLink(type="button" title=_p('rightside.translate_title'))= translate.default
when 'darkmode'
if darkmode.enable && darkmode.button
button#darkmode(type="button" title=_p('rightside.night_mode_title'))
i.fas.fa-adjust
when 'hideAside'
if aside.enable && aside.button && page.aside !== false
button#hide-aside-btn(type="button" title=_p('rightside.aside'))
i.fas.fa-arrows-alt-h
when 'toc'
if showToc
button#mobile-toc-button.close(type="button" title=_p("rightside.toc"))
i.fas.fa-list-ul
when 'chat'
if chat_btn
button#chat_btn(type="button" title=_p("rightside.chat"))
i.fas.fa-sms
when 'comment'
if commentsJsLoad
a#to_comment(href="#post-comment" title=_p("rightside.scroll_to_comment"))
i.fas.fa-comments

#rightside-mask.hidden(onclick="rightside.switchRightSide();")
#rightside.hidden

#rightside-header
#rightside-back
i.fas.fa-chevron-left(onclick="rightside.backRightSide();")
#rightside-title= _p("rightside.setting")
#rightside-close(onclick="rightside.switchRightSide();")
i.fas.fa-xmark
#rightside-content
#card-post-content
if site.categories.length
.card-widget.card-categories
!=aside_categories({ limit: theme.aside.card_categories.limit === 0 ? 0 : theme.aside.card_categories.limit || 8 , expand: theme.aside.card_categories.expand })

if site.tags.length
.card-widget.card-tags
.item-headline
i.fas.fa-tags
span= _p('aside.card_tags')
if theme.aside.card_tags.color
.card-tag-cloud!= cloudTags({source: site.tags, minfontsize: 1.15, maxfontsize: 1.45, limit: 0, unit: 'em'})
else
.card-tag-cloud!= tagcloud({min_font: 1.1, max_font: 1.5, amount: 0 , color: true, start_color: '#999', end_color: '#99a9bf', unit: 'em'})

- const { enable, hide, show } = theme.rightside_item_order
- const hideArray = enable ? hide && hide.split(',') : ['readmode','translate','darkmode','hideAside','toc','chat','comment']
- const showArray = enable ? show && show.split(',') : []


#rightside-config-hide
if hideArray
+rightsideItem(hideArray)
#rightside-config-show
if enable
if hide
button#rightside_config(type="button" title=_p("rightside.setting"))
i.fas.fa-cog.fa-spin
else
if is_post()
if (readmode || translate.enable || (darkmode.enable && darkmode.button))
button#rightside_config(type="button" title=_p("rightside.setting"))
i.fas.fa-cog.fa-spin
else if translate.enable || (darkmode.enable && darkmode.button)
button#rightside_config(type="button" title=_p("rightside.setting"))
i.fas.fa-cog.fa-spin

if showArray
+rightsideItem(showArray)

button#go-up(type="button" title=_p("rightside.back_to_top"))
i.fas.fa-arrow-up

在导航栏添加设置按钮,找到themes\butterfly\layout\includes\header\nav.pug文件,修改如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
nav#nav
span#blog-info
a(href=url_for('/') title=config.title)
if theme.nav.logo
img.site-icon(src=url_for(theme.nav.logo))
if theme.nav.display_title
span.site-name=config.title

#menus
+ div.nav-button#console-button
+ a.site-page.social-icon.console(onclick="rightside.switchRightSide()" title="设置")
+ i.fas.fa-screwdriver-wrench.fa-fw
if (theme.algolia_search.enable || theme.local_search.enable)
#search-button
a.site-page.social-icon.search(href="javascript:void(0);")
i.fas.fa-search.fa-fw
span=' '+_p('search.title')
!=partial('includes/header/menu_item', {}, {cache: true})

#toggle-menu
a.site-page(href="javascript:void(0);")
i.fas.fa-bars.fa-fw

添加css样式

新建source/css/rightside.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
/* 右下角设置按钮 */
#rightside {
z-index: 100;
opacity: 1 !important;
width: 1200px;
max-width: 80vw;
min-height: 250px;
max-height: 90vh;
right: 50%;
bottom: 50%;
padding: 1rem;
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: center;
border-radius: calc(.5rem * 2);
border: 1px solid var(--tab-botton-bg);
-webkit-box-shadow: 0 8px 12px -3px rgba(45, 45, 45, .05);
-moz-box-shadow: 0 8px 12px -3px rgba(45, 45, 45, .05);
-ms-box-shadow: 0 8px 12px -3px rgba(45, 45, 45, .05);
-o-box-shadow: 0 8px 12px -3px rgba(45, 45, 45, .05);
box-shadow: 0 8px 12px -3px rgba(45, 45, 45, .05);
background: rgba(242, 246, 252, .8);
/* backdrop-filter: var(--backdrop-filter); */
backdrop-filter: saturate(240%) blur(35px);
-webkit-transform: translate(50%, 50%) !important;
-moz-transform: translate(50%, 50%) !important;
-ms-transform: translate(50%, 50%) !important;
-o-transform: translate(50%, 50%) !important;
transform: translate(50%, 50%) !important;
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
-ms-transition: all .3s ease-in-out;
-o-transition: all .3s ease-in-out;
transition: all .3s ease-in-out;
}

#rightside.hidden {
z-index: -1;
opacity: 0 !important;
}

#rightside-mask.hidden {
z-index: -1;
opacity: 0 !important;
}

#rightside-mask {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 99;
/* background: rgba(0,0,0,0.6); */
}

#rightside-config-show {
display: flex;
display: none;
align-items: center;
justify-content: center;
flex-wrap: wrap;
}

#rightside-config-hide {
height: auto !important;
opacity: 1 !important;
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
-webkit-transform: translate(0, 0) !important;
-moz-transform: translate(0, 0) !important;
-ms-transform: translate(0, 0) !important;
-o-transform: translate(0, 0) !important;
transform: translate(0, 0) !important;
}

#rightside>div>button,
#rightside>div>a {
position: relative;
color: var(--font-color);
background: var(--card-bg);
border-radius: 50%;
margin: 10px;
width: 50px;
height: 50px;
font-size: 20px;
border: 1px solid var(--tab-botton-bg);
-webkit-box-shadow: 0 8px 12px -3px rgba(45, 45, 45, .05);
-moz-box-shadow: 0 8px 12px -3px rgba(45, 45, 45, .05);
-ms-box-shadow: 0 8px 12px -3px rgba(45, 45, 45, .05);
-o-box-shadow: 0 8px 12px -3px rgba(45, 45, 45, .05);
box-shadow: 0 8px 12px -3px rgba(45, 45, 45, .05);
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
-ms-transition: all .3s ease-in-out;
-o-transition: all .3s ease-in-out;
transition: all .3s ease-in-out;
}

#rightside>div>button.on,
#rightside>div>a.on,
html.hide-aside #hide-aside-btn {
color: var(--white);
background: #FF7242;
border-color: #FF7242;
}


#rightside>div>button:hover,
#rightside>div>a:hover {
color: #fff;
background: rgb(22, 119, 179);
border-color: rgb(22, 119, 179);
-webkit-box-shadow: 0 8px 12px -3px rgba(22, 119, 179, .2);
-moz-box-shadow: 0 8px 12px -3px rgba(22, 119, 179, .2);
-ms-box-shadow: 0 8px 12px -3px rgba(22, 119, 179, .2);
-o-box-shadow: 0 8px 12px -3px rgba(22, 119, 179, .2);
box-shadow: 0 8px 12px -3px rgba(22, 119, 179, .2);
}

#darkmode i.fa-sun {
color: #FF7242 !important;
}

#darkmode i.fa-moon {
opacity: 0;
color: #FFB449 !important;
width: 50px;
left: 0;
position: absolute;
top: 50%;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50%);
}

#darkmode i {
-webkit-transition: all .3s linear;
-moz-transition: all .3s linear;
-ms-transition: all .3s linear;
-o-transition: all .3s linear;
transition: all .3s linear;
}

#rightside #rightside-header {
display: flex;
position: absolute;
top: 1rem;
padding: 0 2rem;
width: 100%;
font-size: 2rem;
}

#rightside #rightside-content {
display: none;
margin-top: 4rem;
}


#rightside #rightside-config-hide,
#rightside #rightside-config-show {
margin-top: 4rem;
}

@media screen and (min-width: 1080px) {
#rightside #rightside-content {
display: block !important;
}

#rightside #rightside-config-hide,
#rightside #rightside-config-show {
margin-top: 0 !important;
}
}


#rightside #rightside-close,
#rightside #rightside-back {
cursor: url(https://npm.elemecdn.com/eurkon-cdn/hexo/images/user/pointer.cur), pointer !important;
}

#rightside #rightside-close:hover,
#rightside #rightside-back:hover {
color: #1677B3;
}

#rightside #rightside-title {
width: 100%;
text-align: center;
line-height: 1.5;
margin-bottom: 4rem;
}

#rightside #rightside-content>div {
display: flex;
flex-wrap: wrap;
align-items: flex-start;
width: 100%;
max-height: calc(90vh - 11rem);
background: var(--card-bg);
border: 1px solid var(--tab-botton-bg);
border-radius: .5rem;
margin: .5rem;
overflow: hidden;
padding: 1rem;
-webkit-box-shadow: 0 8px 12px -3px rgba(45, 45, 45, .05);
-moz-box-shadow: 0 8px 12px -3px rgba(45, 45, 45, .05);
-ms-box-shadow: 0 8px 12px -3px rgba(45, 45, 45, .05);
-o-box-shadow: 0 8px 12px -3px rgba(45, 45, 45, .05);
box-shadow: 0 8px 12px -3px rgba(45, 45, 45, .05);
}

#rightside .item-headline {
font-size: 1.2rem;
}

#rightside .item-headline i {
margin-right: .3rem;
}

#rightside .aside-list {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
}

#rightside .aside-list>.aside-list-item {
position: relative;
width: calc(100%/2 - .25rem);
height: 8rem;
margin: .25rem 0;
background: #F2F6FC;
border: 1px solid var(--tab-botton-bg);
border-radius: .5rem;
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
-ms-transition: all .3s ease-in-out;
-o-transition: all .3s ease-in-out;
transition: all .3s ease-in-out;
}

#rightside #card-newest-comments .aside-list>span {
width: 100%;
text-align: center;
-webkit-transform: translateY(250px);
-moz-transform: translateY(250px);
-ms-transform: translateY(250px);
-o-transform: translateY(250px);
transform: translateY(250px);
}

#rightside #card-newest-comments .aside-list>.aside-list-item img {
width: 2rem;
height: 2rem;
margin: .5rem .5rem 0 .5rem;
border-radius: 50%;
}

#rightside #card-newest-comments .aside-list>.aside-list-item .content {
-webkit-line-clamp: 2;
display: -webkit-box;
overflow: hidden;
padding: .5rem;
margin-top: -.5rem;
-webkit-box-orient: vertical;
}

#rightside #card-newest-comments .aside-list>.aside-list-item .content .name {
position: absolute;
top: .7rem;
left: 3rem;
font-size: .9rem;
}

#rightside #card-newest-comments .aside-list>.aside-list-item .content .comment {
color: var(--font-color);
}

#rightside #card-newest-comments .aside-list>.aside-list-item .content:hover .comment {
color: #1677B3;
}

#rightside .card-recent-post .aside-list>.aside-list-item {
display: flex;
}

#rightside .card-recent-post .aside-list>.aside-list-item .thumbnail>img {
height: 100%;
width: 120px;
object-fit: cover;
border-radius: .5rem 0 0 .5rem;
}

#rightside .card-recent-post .aside-list>.aside-list-item .content {
width: 100%;
padding: .5rem;
background: #F2F6FC;
border-radius: 0 .5rem .5rem 0;
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
-ms-transition: all .3s ease-in-out;
-o-transition: all .3s ease-in-out;
transition: all .3s ease-in-out;
}

#rightside .card-recent-post .aside-list>.aside-list-item .content .title {
color: var(--font-color);
line-height: 1.5;
font-size: 1.1rem;
-webkit-line-clamp: 2;
overflow: hidden;
-webkit-box-orient: vertical;
display: -webkit-box;
font-weight: bold;
height: 3.5rem;
margin: .5rem 0;
}

#rightside .card-recent-post .aside-list>.aside-list-item .content time {
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
-ms-transition: all .3s ease-in-out;
-o-transition: all .3s ease-in-out;
transition: all .3s ease-in-out;
}

#rightside .card-recent-post .aside-list>.aside-list-item:hover .content time {
color: #fff;
}

#rightside .card-recent-post .aside-list>.aside-list-item:hover .content {
background: rgb(22, 119, 179);
}

#rightside .card-recent-post .aside-list>.aside-list-item:hover .content .title {
color: #fff !important;
}

#rightside #card-post-content .card-widget {
width: 100%;
}

#rightside .card-categories ul.card-category-list {
padding: 0;
list-style: none;
display: flex;
flex-flow: wrap;
justify-content: space-between;
margin-top: 0;
margin-bottom: .5rem;
}

#rightside .card-categories ul.card-category-list>.card-category-list-item {
width: calc(100% / 2 - .5rem);
margin-top: .5rem;
}

#rightside .card-categories ul.card-category-list>.card-category-list-item a {
color: var(--font-color);
padding: 3px 8px;
border-radius: .5rem;
background: #F2F6FC;
display: flex;
flex-direction: column;
}

#rightside .card-categories ul.card-category-list>.card-category-list-item a:hover {
padding: 3px 17px;
color: #fff !important;
background: rgb(22, 119, 179);
-webkit-box-shadow: 0 8px 12px -3px rgba(22, 119, 179, .2);
-moz-box-shadow: 0 8px 12px -3px rgba(22, 119, 179, .2);
-ms-box-shadow: 0 8px 12px -3px rgba(22, 119, 179, .2);
-o-box-shadow: 0 8px 12px -3px rgba(22, 119, 179, .2);
box-shadow: 0 8px 12px -3px rgba(22, 119, 179, .2);
}

#rightside .card-categories ul.card-category-list>.card-category-list-item a span {
overflow: visible;
}

#rightside .card-categories ul.card-category-list>.card-category-list-item a span.card-category-list-name {
opacity: 1;
font-weight: bold;
}

#rightside .card-categories ul.card-category-list>.card-category-list-item a span.card-category-list-count {
position: relative;
line-height: 2rem;
font-size: 1.5rem;
font-weight: bold;
text-align: right;
}

#rightside .card-categories ul.card-category-list>.card-category-list-item a span.card-category-list-count::after {
content: '篇';
opacity: .8;
font-size: 1rem;
margin-left: .5rem;
}

#rightside .card-tag-cloud a {
display: inline-block;
font-size: 1.1rem !important;
color: var(--font-color) !important;
padding: 0rem .3rem;
margin: .2rem;
border: 1px solid var(--tab-botton-bg);
border-radius: .5rem;
background: #F2F6FC;
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
-ms-transition: all .3s ease-in-out;
-o-transition: all .3s ease-in-out;
transition: all .3s ease-in-out;
}

#rightside .card-tag-cloud a:hover {
color: #fff !important;
background: rgb(22, 119, 179);
border-color: rgb(22, 119, 179);
-webkit-transition: all .3s ease-in-out;
-moz-transition: all .3s ease-in-out;
-ms-transition: all .3s ease-in-out;
-o-transition: all .3s ease-in-out;
transition: all .3s ease-in-out;
-webkit-box-shadow: 0 8px 12px -3px rgba(22, 119, 179, .2);
-moz-box-shadow: 0 8px 12px -3px rgba(22, 119, 179, .2);
-ms-box-shadow: 0 8px 12px -3px rgba(22, 119, 179, .2);
-o-box-shadow: 0 8px 12px -3px rgba(22, 119, 179, .2);
box-shadow: 0 8px 12px -3px rgba(22, 119, 179, .2);
}

#rightside .card-tag-cloud a sup {
margin-left: .1em;
}

添加js脚本

新建source/js/rightside.js文件,内容如下:

1
2
3
4
5
6
7
var rightside = {
// RightSide设置
switchRightSide: function () {
document.getElementById('rightside')?.classList.toggle('hidden')
document.getElementById('rightside-mask')?.classList.toggle('hidden')
},
}

引入js脚本和css样式

修改 _config.butterfly.yml 主题配置文件,修改内容如下:

1
2
3
4
5
6
7
8
9
10
# Inject
# Insert the code to head (before '</head>' tag) and the bottom (before '</body>' tag)
# 插入代码到头部 </head> 之前 和 底部 </body> 之前
inject:
head:
# 自定义css
+ - <link rel="stylesheet" href="/css/rightside.css"> #添加的自定义css文件
bottom:
# 自定义js
+ - <script async data-pjax src="/js/rightside.js"></script> #添加的自定义js文件

Hexo三连

1
hexo clean && hexo g && hexo s