
博客魔改教程:在中控台添加帧率显示功能
文章摘要
MxGPT
本文提供了一个博客魔改教程,教你如何在博客的中控台中添加帧率显示功能。通过修改相关文件和添加自定义脚本,你可以在博客中实时显示帧率,以便进行性能优化和调试。详细的步骤和代码示例都在文章中提供,让你轻松实现这一功能。优化博客的同时,也能提升用户体验和浏览效果。
此内容根据文章生成,并经过人工审核,仅用于文章内容的解释与总结
投诉针对不同博客,改动略有不同,本文仅供参考,我这里把fps开关放到了中控台
效果预览
魔改步骤
- 修改 themes/butterfly/layout/includes/header/nav.pug
1
2
3
4
5
6
7
8
9#page-name-mask
#page-name
a#page-name-text(onclick= 'btf.scrollToDest(0,500)')=navTitleName
#menus
!=partial('includes/header/menu_item', {}, {cache: true})
+ #nav-left
+ #fps-group
+ #fps
+ span.fpsText=_p('FPS') - 修改 themes/butterfly/layout/includes/console.pug
1
2
3
4
5
6
7
8
9
10if theme.console.keyboard.enable
.console-btn-item#consoleKeyboard(onclick='manxin.keyboardToggle()', title='快捷键开关')
a.keyboard-switch
i.fas.fa-keyboard
.console-btn-item#consoleCommentBarrage(onclick='manxin.switchCommentBarrage()', title='热评开关')
a.commentBarrage
i.fa-solid.fa-message
+ .console-btn-item#consoleFPS(onclick='manxin.FPSToggle()', title='帧率显示开关')
+ a.FPS-switch
+ i.fas.fa-gauge - 新建 themes/butterfly/source/manxin/fps.js(引入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
50let Jay_showFPS = !1;
"true" === localStorage.getItem("showFPS") ?
((Jay_showFPS = !0),
document.querySelector("#fps-group").classList.add("show"),
document.querySelector("#consoleFPS").classList.add("on")) :
((Jay_showFPS = !1),
document.querySelector("#fps-group").classList.remove("show"),
document.querySelector("#consoleFPS").classList.remove("on"));
var showFPS = (function() {
let e,
t,
o,
n,
a,
i =
window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(e) {
window.setTimeout(e, 1e3 / 60);
};
(e = 0),
(t = Date.now()),
(n = function() {
(o = Date.now() - t),
(e += 1),
o >= 1e3 && ((t += o), a(e), (e = 0)),
i(n);
}),
(a = function(e) {
$("#fps").html(e);
}),
n();
})();
var manxin = {
FPSToggle: function() {
Jay_showFPS
?
((Jay_showFPS = !1),
document.querySelector("#fps-group").classList.remove("show"),
document.querySelector("#consoleFPS").classList.remove("on"),
localStorage.setItem("showFPS", "false")) :
((Jay_showFPS = !0),
document.querySelector("#fps-group").classList.add("show"),
document.querySelector("#consoleFPS").classList.add("on"),
localStorage.setItem("showFPS", "true"));
},
}; - 新建 themes/butterfly/source/manxin/fps.css(引入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/* FPS */
#fps-group.show {
opacity: 1;
}
.nav-fixed #fps-group,
.not-top-img #fps-group {
color: var(--Jay-fontcolor);
}
#fps-group {
opacity: 0;
display: flex;
flex-direction: column;
margin-left: 16px;
color: var(--Jay-white);
}
#fps {
z-index: 10000;
font-size: 12px;
font-weight: 700;
transition: all 0.3s ease 0s;
line-height: 1;
}
#fps-group .fpsText {
font-size: 12px;
line-height: 1;
opacity: 0.6;
}
/* FPS */
- 感谢你赐予我前进的力量
打赏者名单
因为你们的支持让我意识到写文章的价值🙏
本文是原创文章,采用CC BY-NC-ND 4.0协议,完整转载请注明来自满心记
评论
匿名评论
隐私政策
✅ 你无需删除空行,直接评论以获取最佳展示效果