自定义代码

V1 中的自定义代码

这篇文档将会介绍 V1 中的自定义代码。

变量名含义示例
window.CustomBackgroundImage自定义背景图
window.CustomMobileBackgroundImage自定义手机端背景图
window.CustomLogo自定义Logo示例:"https://...png"
window.CustomDesc自定义描述
window.ShowNetTransfer卡片显示上下行流量true
window.DisableAnimatedMan关掉动画人物插图true
window.CustomIllustration自定义插图(请移除DisableAnimatedMan)
window.FixedTopServerName固定顶部服务器名称true
window.CustomLinks自定义外链[{\"link\":\"https://github.com/hamster1963/nezha-dash\",\"name\":\"GitHub\"}]
window.ForceTheme强制默认颜色主题"light" 或 "dark"
window.ForceUseSvgFlag强制使用 SVG 旗帜true
window.ForceShowServices强制显示服务面板true
window.ForceShowMap强制显示地图true
window.ForceCardInline强制列表单行显示true
window.ForcePeakCutEnabled强制开启延迟图表削峰true
window.ForceSortType默认排序类型default
window.ForceSortOrder默认排序顺序asc
自定义代码填写位置
外部链接效果

原始 json 格式:

[
{ "link": "https://github.com/hamster1963/nezha-dash", "name": "GitHub" },
{ "link": "https://buycoffee.top/coffee", "name": "Buycoffee☕️" }
]

需要对 json 进行转义,然后填入环境变量中。可通过 https://www.jsont.run 转义。

json 转义

转换结果如下:

[{\"link\":\"https://github.com/hamster1963/nezha-dash\",\"name\":\"GitHub\"}]

填写示例

<script>
window.CustomBackgroundImage = 'https://....png'
window.CustomMobileBackgroundImage = 'https://....png'
window.CustomLogo = 'https://....png'
window.CustomDesc = '这是一个自定义描述'
window.ShowNetTransfer = true
window.DisableAnimatedMan = false
window.CustomIllustration = 'https://....png'
window.FixedTopServerName = true
window.CustomLinks =
'[{"link":"https://github.com/hamster1963/nezha-dash","name":"GitHub"}]'
window.ForceTheme = 'light'
</script>