博客功能更新 —— 增加live2D
安装插件
1
| npm install hexo-oh-my-live2d
|
配置参数
添加代码
在 _config.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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
| OhMyLive2d: enable: true CDN: https://unpkg.com/oh-my-live2d option: dockedPosition: 'left' menus: items: | (defaultItems)=>{ return [] }
mobileDisplay: false models: - path: /live2d-models/云吞kumo/云吞kumo.model3.json position: [-15, 5] scale: 0.07 stageStyle: width: 300 height: 540 mobilePosition: [-10, 23] mobileScale: 0.1 mobileStageStyle: width: 180 height: 166 motionPreloadStrategy: ALL parentElement: document.body primaryColor: 'var(--btn-bg)' sayHello: false tips: style: width: 230 height: 120 left: calc(50% - 20px) top: -100px mobileStyle: width: 180 height: 80 left: calc(50% - 30px) top: -100px idleTips: interval: 3600 message: | function(){ return axios.get('https://v1.hitokoto.cn?c=i') .then(function (response) { return response.data.hitokoto ; }) .catch(function (error) { console.error(error); }); }
|
舞台旁按钮关闭
如果觉得舞台边上的按钮看着比较烦人,可以直接给以下代码取消注释。
1 2 3 4 5 6 7
| menus: items: | (defaultItems)=>{ return [] }
|
模型文件的放置
在 source 文件夹里新建一个文件夹,里面放置模型文件,这里我命名为 live2d-models
然后把下载的模型放进去,模型文件选择参考我的 - path: /live2d-models/云吞kumo/云吞kumo.model3.json
live2d云端不加载问题
在github.io访问的时候一切都很正常,但是我使用域名解析后,通过域名访问直接让live2d神秘消失了!
打开控制台一看,原来是国内域名访问不了镜像。
解决方法
- 直接提前下载好镜像中的
index.min.js 文件
- 存放在
source/live2d-models 里
- 将
_config.yml 文件中下面内容进行修改:
1 2 3
| OhMyLive2d: enable: true CDN: /live2d/index.min.js
|