个性化2.0增加了首页文章阴影、右下角萌物、网页标题欺骗、页脚底部显示运行天数

首页文章阴影

~/MyBlog/themes/next/source/css/_custom/custom.styl中加入以下代码

1
2
3
4
5
6
7
.post {
margin-top: 60px;
margin-bottom: 60px;
padding: 25px;
-webkit-box-shadow: 0 0 5px rgba(202, 203, 203, .5);
-moz-box-shadow: 0 0 5px rgba(202, 203, 204, .5);
}

右下角萌物

安装插件
npm install --save hexo-helper-live2d

下载喜欢的萌物,终端输入下面代码进行安装
npm install {packagename}

打开 ~/MyBlog/_config.yml在底部加入以下代码

1
2
3
4
5
6
7
8
9
10
11
live2d:
enable: true
scriptFrom: local
model:
use: live2d-widget-model-haruto
display:
position: right
width: 150
height: 300
mobile:
show: true

并将 live2d-widget-model-haruto换成自己的模型名字
width、height可以修改显示的位置

网页标题欺骗

参考自:asdfv1929的Blog

~/MyBlog/themes/next/source/js/src路径下创建一个 crash_cheat.js文件,并写入以下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<!--崩溃欺骗-->
var OriginTitle = document.title;
var titleTime;
document.addEventListener('visibilitychange', function () {
if (document.hidden) {
$('[rel="svg"]').attr('href', "./MyBlog/themes/next/source/images/logo.svg");
document.title = '╭(°A°`)╮ 页面崩溃啦 ~';
clearTimeout(titleTime);
}
else {
$('[rel="svg"]').attr('href', "../next/source/images/logo.svg");
document.title = '(ฅ>ω<*ฅ) 噫又好了~';
titleTime = setTimeout(function () {
document.title = OriginTitle;
}, 2000);
}
});

打开 ~/MyBlog/themes/next/layout/_layout.swig,在底部插入以下代码

1
2
<!--崩溃欺骗-->
<script type="text/javascript" src="/js/src/crash_cheat.js"></script>

页脚显示网站运行天数

打开 ~/MyBlog/themes/next/layout/_partials/footer.swig,在适当的位置插入以下代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<span id="timeDate">载入天数...</span><span id="times">载入时分秒...</span></br>
<script>
var now = new Date();
function createtime() {
var grt= new Date("02/21/2019 13:00:00");//此处修改你的建站时间或者网站上线时间
now.setTime(now.getTime()+250);
days = (now - grt ) / 1000 / 60 / 60 / 24; dnum = Math.floor(days);
hours = (now - grt ) / 1000 / 60 / 60 - (24 * dnum); hnum = Math.floor(hours);
if(String(hnum).length ==1 ){hnum = "0" + hnum;} minutes = (now - grt ) / 1000 /60 - (24 * 60 * dnum) - (60 * hnum);
mnum = Math.floor(minutes); if(String(mnum).length ==1 ){mnum = "0" + mnum;}
seconds = (now - grt ) / 1000 - (24 * 60 * 60 * dnum) - (60 * 60 * hnum) - (60 * mnum);
snum = Math.round(seconds); if(String(snum).length ==1 ){snum = "0" + snum;}
document.getElementById("timeDate").innerHTML = "本站已安全运行 "+dnum+" 天 ";
document.getElementById("times").innerHTML = hnum + " 小时 " + mnum + " 分 " + snum + " 秒";
}
setInterval("createtime()",250);
</script>

完!