紅葉~
L
O
A
D
I
N
G
紅葉
有趣的小东西

有趣的小东西

🎁 本文内容
平时攒下来的小网站、VS Code 好玩插件、安卓模拟器,以及这个博客加特效、加看板娘的折腾记录。

🔗 1. 有点用的小网站

🧩 2. VS Code 好玩插件

用途 插件
🤖 AI 补全代码、写注释 GitHub Copilot、TONGYI Lingma、CodeGeeX(功能差不多,挑一个)
📝 Markdown 预览 Markdown Preview Github Styling、Markdown All in One
🌏 划词翻译 Code Translate
📸 代码截图 CodeSnap

📱 3. 安卓模拟器

✨ 4. 博客折腾记录

本博客用 Hexo 作为框架,Kira 作为主题:kira-hexo

💗 鼠标点击爱心效果

在 hexo-theme-kira/source/js/ 下新建 love.js,写入以下代码:

1
!function(e,t,a){function n(){c(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 500%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"),o(),r()}function r(){for(var e=0;e<d.length;e++)d[e].alpha<=0?(t.body.removeChild(d[e].el),d.splice(e,1)):(d[e].y--,d[e].scale+=.004,d[e].alpha-=.013,d[e].el.style.cssText="left:"+d[e].x+"px;top:"+d[e].y+"px;opacity:"+d[e].alpha+";transform:scale("+d[e].scale+","+d[e].scale+") rotate(45deg);background:"+d[e].color+";z-index:99999");requestAnimationFrame(r)}function o(){var t="function"==typeof e.onclick&&e.onclick;e.onclick=function(e){t&&t(),i(e)}}function i(e){var a=t.createElement("div");a.className="heart",d.push({el:a,x:e.clientX-5,y:e.clientY-5,scale:1,alpha:1,color:s()}),t.body.appendChild(a)}function c(e){var a=t.createElement("style");a.type="text/css";try{a.appendChild(t.createTextNode(e))}catch(t){a.styleSheet.cssText=e}t.getElementsByTagName("head")[0].appendChild(a)}function s(){return"rgb("+~~(255*Math.random())+","+~~(255*Math.random())+","+~~(255*Math.random())+")"}var d=[];e.requestAnimationFrame=function(){return e.requestAnimationFrame||e.webkitRequestAnimationFrame||e.mozRequestAnimationFrame||e.oRequestAnimationFrame||e.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)}}(),n()}(window,document);

然后在 hexo-theme-kira/layout/ 下,除了 layout.ejs 以外的每个 .ejs 文件末尾加上下面这段(少加一个,那个页面就没有效果):

1
2
<!-- 页面点击小红心 -->
<script type="text/javascript" src="/js/love.js"></script>

完成后点击鼠标,就能看到爱心特效了 💕

🐶 Live2D 看板娘(入门版)

最基础的看板娘,用 npm 装插件就行:

1
npm install --save hexo-helper-live2d

这个插件的模型数量有限,只能从别人配置好的里面挑。然后在 Hexo 的 _config.yml 中添加如下配置,详细说明见官方文档:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
live2d:
enable: true
scriptFrom: local
pluginRootPath: live2dw/
pluginJsPath: lib/
pluginModelPath: assets/
tagMode: false
debug: false
model:
use: live2d-widget-model-wanko
display:
position: right
width: 150
height: 300
mobile:
show: true
react:
opacity: 0.7

🎀 进阶:自定义看板娘

我用的是 stevenjoezhang/live2d-widget,可以换成自己找的模型文件,做一个专属看板娘。

剩下的自己琢磨去,问就是我也忘了,反正挺麻烦的 🙃

🕸️ 动态线条背景

1
2
3
<script type="text/javascript"
color="255,192,203" opacity="1.0" zIndex="-2" count="750"
src="//cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js"></script>
参数 含义
color 线条颜色(RGB),这里用的是博客的粉色
zIndex 图层层级,负数表示放在最底层
count 线条数量

🔍 搜索栏

我忘了。

本文作者:紅葉
本文链接:https://swe-et.github.io/funny/
版权声明:本文采用 CC BY-NC-SA 3.0 CN 协议进行许可