此功能用于刷新浏览器网站的缓存,用以查看最新的文章或者解决缓存问题

新建Javascript文件

1
2
3
function refreshCache() {
if (confirm('是否确定刷新博文缓存')) location.reload()
}


修改rightside.pug

路径: [butterfly]\layout\includes\

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
      when 'comment'
if commentsJsLoad
a#to_comment(href="#post-comment" title=_p("rightside.scroll_to_comment"))
i.fas.fa-comments
+ when 'refresh'
+ button#refresh-cache(type="button" title='刷新缓存' onclick="refreshCache()")
+ i.fas.fa-refresh.fa-spin

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


#rightside-config-hide
if hideArray
+rightsideItem(hideArray)


修改_config.butterfly.yml

1
2
3
4
5
6
7
8
9
# Inject
# Insert the code to head (before '</head>' tag) and the bottom (before '</body>' tag)
# 插入代码到头部 </head> 之前 和 底部 </body> 之前
inject:
head:
...
bottom:
# 缓存刷新按钮
- <script type="text/javascript" src="/js/新建的.js"></script>