点击查看更新记录
更新记录
2021-11-25:订正插件文档错误
- 订正插件文档CDN依赖项的url错误。
2021-09-02:发布插件版
- 发布NPM插件版本
- 和页脚徽标联动
- 支持自定义配置
2021-02-08:稳定版v1.0
- 使用原生JS实现页脚计时器。
- 添加营业中,打烊了牌子。
- 添加夜间模式下呼吸灯效果。
魔改步骤
旧版引入方案
- 新建[Blogroot]\themes\butterfly\source\js\runtime.js,此处用到了shield.io生成徽标,更多内容请参看站内教程:博客添加github徽标方案: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
 39setInterval(() => { 
 let create_time = Math.round(new Date('2019-04-17 00:00:00').getTime() / 1000); //在此行修改建站时间
 let timestamp = Math.round((new Date().getTime()) / 1000);
 let second = timestamp - create_time;
 let time = new Array(0, 0, 0, 0, 0);
 //格式规范化,个位数前面加0
 var nol = function(h){
 return h>9?h:'0'+h;
 }
 if (second >= 365 * 24 * 3600) {
 time[0] = parseInt(second / (365 * 24 * 3600));
 second %= 365 * 24 * 3600;
 }//年
 if (second >= 24 * 3600) {
 time[1] = parseInt(second / (24 * 3600));
 second %= 24 * 3600;
 }//天
 if (second >= 3600) {
 time[2] = nol(parseInt(second / 3600));
 second %= 3600;
 }//时
 if (second >= 60) {
 time[3] = nol(parseInt(second / 60));
 second %= 60;
 }//分
 if (second > 0) {
 time[4] = nol(second);
 }//秒
 //早上7点到晚上10点营业
 if ((Number(time[2])<22) && (Number(time[2])>7)){
 currentTimeHtml ="<img class='boardsign' src='https://img.shields.io/badge/资源宝-营业中-6adea8?style=social&logo=cakephp' title='距离百年老店也就差不到一百年~'><div id='runtime'>" + time[0] + ' YEAR ' + time[1] + ' DAYS ' + time[2] + ' : ' + time[3] + ' : ' + time[4] + '</div>';
 } //徽标内容参考站内教程
 //其余时间打烊
 else{
 currentTimeHtml ="<img class='boardsign' src='https://img.shields.io/badge/资源宝-打烊了-6adea8?style=social&logo=coffeescript' title='这个点了应该去睡觉啦,熬夜对身体不好哦'><div id='runtime'>" + time[0] + ' YEAR ' + time[1] + ' DAYS ' + time[2] + ' : ' + time[3] + ' : ' + time[4] + '</div>'; //徽标内容参考站内教程
 }
 //覆写挂载标签的内容
 document.getElementById("workboard").innerHTML = currentTimeHtml;
 }, 1000);
- 修改[Blogroot]\themes\butterfly\layout\includes\footer.pug,添加计时器的挂载标签:1 
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11if theme.footer.copyright 
 .framework-info
 span= _p('footer.framework') + ' '
 a(href='https://hexo.io')= 'Hexo'
 span.footer-separator |
 span= _p('footer.theme') + ' '
 a(href='https://github.com/jerryc127/hexo-theme-butterfly')= 'Butterfly'
 if theme.footer.custom_text
 .footer_custom_text!=`${theme.footer.custom_text}`
 + #workboard
 + script(async src=url_for(theme.CDN.runtime))
- 新建[Blogroot]\themes\butterfly\source\css\_layout\runtime.styl,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/*电子钟字体*/ 
 @font-face
 font-family 'UnidreamLED'
 src url('https://npm.elemecdn.com/测试-candyassets/fonts/UnidreamLED.ttf')
 font-display swap
 //页脚计时器
 div#runtime
 width 180px
 margin auto
 color white
 padding-inline 5px
 border-radius 10px
 background-color rgba(0,0,0,0.7)
 font-family 'UnidreamLED'
 // 夜间全局透明度
 [data-theme="dark"]
 div#runtime
 color rgb(40, 180, 200)
 box-shadow 0 0 5px rgba(28, 69, 218, 0.71)
 animation flashlight 1s linear infinite alternate
 @keyframes flashlight
 from
 box-shadow 0 0 5px rgb(20, 120, 210)
 to
 box-shadow 0 0 2px rgb(20, 120, 210)
- 修改_config.butterfly.yml,添加CDN链接:1 
 2
 3
 4
 5
 6
 7
 8CDN: 
 # main
 main_css: /css/index.css
 jquery: https://npm.elemecdn.com/jquery@latest/dist/jquery.min.js
 main: /js/main.js
 utils: /js/utils.js
 # 页脚计时器
 + runtime: /js/runtime.js
新版NPM插件方案
NPM插件方案和页脚徽标捆绑,但是可以分别选择是否打开对应模块。
- 安装插件,在博客根目录 - [Blogroot]下打开终端,运行以下指令:- 1 - npm install hexo-butterfly-footer-beautify --save 
- 添加配置信息,以下为写法示例 
 在站点配置文件- _config.yml或者主题配置文件- _config.butterfly.yml中添加- 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- # footer_beautify 
 # 页脚计时器:[Native JS Timer](/posts/b941af/)
 # 页脚徽标:[Add Github Badge](/posts/e87ad7f8/)
 footer_beautify:
 enable:
 timer: true # 计时器开关
 bdage: true # 徽标开关
 priority: 5 #过滤器优先权
 enable_page: all # 应用页面
 exclude: #屏蔽页面
 # - /posts/
 # - /about/
 layout: # 挂载容器类型
 type: id
 name: footer-wrap
 index: 0
 # 计时器部分配置项
 runtime_js: https://npm.elemecdn.com/hexo-butterfly-footer-beautify@1.0.0/lib/runtime.js
 runtime_css: https://npm.elemecdn.com/hexo-butterfly-footer-beautify@1.0.0/lib/runtime.css
 # 徽标部分配置项
 swiperpara: 3 #若非0,则开启轮播功能,每行徽标个数
 bdageitem:
 - link: https://hexo.io/ #徽标指向网站链接
 shields: https://img.shields.io/badge/Frame-Hexo-blue?style=flat&logo=hexo #徽标API
 message: 博客框架为Hexo_v5.4.0 #徽标提示语
 - link: https://butterfly.js.org/
 shields: https://img.shields.io/badge/Theme-Butterfly-6513df?style=flat&logo=bitdefender
 message: 主题版本Butterfly_v3.8.2
 - link: https://www.jsdelivr.com/
 shields: https://img.shields.io/badge/CDN-jsDelivr-orange?style=flat&logo=jsDelivr
 message: 本站使用JsDelivr为静态资源提供CDN加速
 - link: https://vercel.com/
 shields: https://img.shields.io/badge/Hosted-Vercel-brightgreen?style=flat&logo=Vercel
 message: 本站采用双线部署,默认线路托管于Vercel
 - link: https://vercel.com/
 shields: https://img.shields.io/badge/Hosted-Coding-0cedbe?style=flat&logo=Codio
 message: 本站采用双线部署,联通线路托管于Coding
 - link: https://github.com/
 shields: https://img.shields.io/badge/Source-Github-d021d6?style=flat&logo=GitHub
 message: 本站项目由Github托管
 - link: http://creativecommons.org/licenses/by-nc-sa/4.0/
 shields: https://img.shields.io/badge/Copyright-BY--NC--SA%204.0-d42328?style=flat&logo=Claris
 message: 本站采用知识共享署名-非商业性使用-相同方式共享4.0国际许可协议进行许可
 swiper_css: https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiper.min.css
 swiper_js: https://npm.elemecdn.com/hexo-butterfly-swiper/lib/swiper.min.js
 swiperbdage_init_js: https://npm.elemecdn.com/hexo-butterfly-footer-beautify/lib/swiperbdage_init.min.js
- 参数释义
| 参数 | 备选值/类型 | 释义 | 
|---|---|---|
| priority | number | 【可选】过滤器优先级,数值越小,执行越早,默认为10,选填 | 
| enable.timer | true/false | 【必选】计时器控制开关 | 
| enable.bdage | true/false | 【必选】徽标控制开关 | 
| enable_page | path | 【可选】填写想要应用的页面,如根目录就填’/‘,分类页面就填’/categories/‘。若要应用于所有页面,就填 all,默认为all | 
| exclude | path | 【可选】填写想要屏蔽的页面,可以多个。仅当enable_page为’all’时生效。写法见示例。原理是将屏蔽项的内容逐个放到当前路径去匹配,若当前路径包含任一屏蔽项,则不会挂载。 | 
| layout.type | id/class | 【可选】挂载容器类型,填写id或class,不填则默认为id | 
| layout.name | text | 【必选】挂载容器名称 | 
| layout.index | 0和正整数 | 【可选】前提是layout.type为class,因为同一页面可能有多个class,此项用来确认究竟排在第几个顺位 | 
| runtime_js | url | 【必选】页脚计时器脚本,可以下载上文填写示例的链接,参照注释和教程:Native JS Timer自行修改。 | 
| runtime_css | url | 【可选】自定义样式,预留开发者接口,可自行下载。 | 
| swiperpara | number | 【可选】若非零,则开启轮播功能,此项表示每行最多容纳徽标个数,用来应对徽标过多显得页脚拥挤的问题 | 
| bdageitem.link | url | 【可选】页脚徽标指向的网站链接 | 
| bdageitem.shields | url | 【必选】页脚徽标对应的API,API具体写法示例参照教程Add Github Badge | 
| bdageitem.message | text | 【可选】页脚徽标悬停时显示的信息 | 
| swiper_css | url | 【可选】swiper的依赖 | 
| swiper_js | url | 【可选】swiper的依赖 | 
| swiperbdage_init_js | url | 【可选】swiper初始化方法 | 
TO DO
夜间模式适配
原生js实现
添加营业中,打烊了牌子
NPM插件化

Invitation
测试
created:14/10/2022
Welcome to Candyhome
Use this card to join the candyhome and participate in a pleasant discussion together .
Welcome to 测试's candyhome,wish you a nice day .
 评论








