针对不同博客,改动略有不同,本文仅供参考,我这里把fps开关放到了中控台

效果预览

魔改步骤
  1. 修改 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')
  2. 修改 themes/butterfly/layout/includes/console.pug
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    if 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
  3. 新建 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
    50
    let 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"));
    },
    };
  4. 新建 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 */