请注意,本文编写于 1110 天前,最后修改于 203 天前,其中某些信息可能已经过时。
不全但应该是全网第二详细的
以下教程均以handsome version 7.3.1 Pro主题为例,仅供参考
1.彩色标签和博客信息
进入网站后台,点击外观
->设置外观
->主题增强功能
->增强功能开关
->启用PJAX
,然后点击PJAX
->PJAX回调函数
,粘贴下面这段代码
let tags = document.querySelectorAll("#tag_cloud-2 a,.list-group-item .pull-right");
let colorArr = ["#86d2f3", "#a3dbf3", "#5dbde7", "#6b7ceb", "#919ff5", "#abb6f5"];
tags.forEach(tag =>{
tagsColor = colorArr[Math.floor(Math.random() * colorArr.length)];
tag.style.backgroundColor = tagsColor
});
点击开发者设置
->自定义 JavaScript
,粘贴下面这段代码
<!--彩色标签云&博客信息-->
let tags = document.querySelectorAll("#tag_cloud-2 a,.list-group-item .pull-right");
let colorArr = ["#86d2f3", "#a3dbf3", "#5dbde7", "#6b7ceb", "#919ff5", "#abb6f5"];
tags.forEach(tag =>{
tagsColor = colorArr[Math.floor(Math.random() * colorArr.length)];
tag.style.backgroundColor = tagsColor
});
2.博客信息增加访问总量统计
在./usr/themes/handsome/functions.php
文件中添加以下统计代码,添加位置:最底部
//总访问量
function theAllViews()
{
$db = Typecho_Db::get();
$row = $db->fetchAll('SELECT SUM(VIEWS) FROM `typecho_contents`');
echo number_format($row[0]['SUM(VIEWS)']);
}
在./usr/themes/handsome/component/sidebar.php
文件中插入以下代码,添加位置:在博客信息
字样下,自定义选择显示位置,但注意要在上一个 badge
和下一个 pull-right
之间插入,这里我选择在99行插入,使其显示在运行天数下,如图:
pull-right"><?php echo theAllViews();?></span><?php _me("访客总数") ?></li>
<li class="list-group-item"> <i class="glyphicon glyphicon-user text-muted"></i> <span class="badge
添加完毕保存 sidebar.php
,刷新网页即可。
3.在文章底部添加版权声明信息
详细步骤请看这篇
4.显示全站字数统计
详细步骤请看这篇
5.赞赏按钮呼吸闪烁效果
进入网站后台,点击外观
->设置外观
->开发者设置
->自定义 CSS
,粘贴以下代码并保存设置:
.btn-pay {
animation: star 0.5s ease-in-out infinite alternate;
}
@keyframes star {
from {
transform: scale(1);
}
to {
transform: scale(1.1);
}
}
6.去除底部主题版权信息展示
打开 ./usr/themes/handsome/component
目录下的 footer.php
,在第13行注释或者删除掉显示内容。
7.去除首页右侧最新评论和随机文章
首页右侧默认有三个分类:热门文章、最新评论、随机文章,但是在加密文章中的评论会直接显示在最新评论中,为了隐私,建议将其去除。
打开 ./usr/themes/handsome/component
目录下的 sibebar.php
,在第12行、29行、44行注释有关评论的代码(不注释第44行会造成热门文章和博客信息下间隔过大)