-
Notifications
You must be signed in to change notification settings - Fork 471
Huge updates #27
Huge updates #27
Changes from 8 commits
4ad70f5
a992565
4a79abe
b3041f3
d5a6c9b
58453ec
1ae7b69
9045f96
f22ce35
48a84c7
e18da32
7570106
e8332a2
5fc7796
94560f7
97ad909
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,28 +4,6 @@ var url = require("url"); | |
|
||
var generators = new Array(); | ||
|
||
var models = { | ||
"Epsilon2.1": "Epsilon2.1/Epsilon2.1.model.json", | ||
"Gantzert_Felixander": "Gantzert_Felixander/model.json", | ||
"haru": "haru/haru.model.json", | ||
"miku": "miku/miku.model.json", | ||
"ni-j": "nito/ni-j.model.json", | ||
"nico": "nito/nico.model.json", | ||
"nito": "nito/nito.model.json", | ||
"nipsilon": "nito/nipsilon.model.json", | ||
"nietzsche": "nito/nietzche.model.json", | ||
"shizuku": "shizuku/shizuku.model.json", | ||
"tsumiki": "tsumiki/tsumiki.model.json", | ||
"wanko": "wanko/wanko.model.json", | ||
"z16": "z16/z16.model.json", | ||
"hibiki": "hibiki/hibiki.model.json", | ||
"koharu": "koharu/koharu.model.json", | ||
"haruto": "haruto/haruto.model.json", | ||
"Unitychan": "Unitychan/unitychan.model.json", | ||
"tororo": "tororo/tororo.model.json", | ||
"hijiki": "hijiki/hijiki.model.json", | ||
} | ||
|
||
function registerFile(pathname, file) { | ||
generators.push({ | ||
path: pathname, | ||
|
@@ -42,38 +20,68 @@ function registerDir(pathname, dir) { | |
}, this); | ||
} | ||
|
||
hexo.extend.generator.register('live2d', function (locals) { | ||
return generators; | ||
}); | ||
|
||
registerDir('live2d/assets/', path.resolve(__dirname, './assets')); | ||
registerFile('live2d/script.js', path.resolve(__dirname, './dist/bundle.js')) | ||
|
||
hexo.extend.helper.register('live2d', function (config) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这里的 config 参数是否应该删除 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 嗯,意思是这个hexo.helper只要传递一堆字符串就可以了吗?那个function(config)里的config变量是没用的? |
||
var config = Object.assign( | ||
{ | ||
model:"z16", | ||
model: "z16", | ||
width: 150, | ||
height: 300, | ||
mobileShow: "true", | ||
mobileWidth: 75, | ||
mobileHeight: 150, | ||
position: "right", | ||
horizontalOffset: 0, | ||
bottomOffset: -20, | ||
className: "live2d", | ||
id: "live2dcanvas", | ||
bottom: -20 | ||
}, | ||
config, | ||
hexo.config.live2d | ||
); | ||
|
||
return ` | ||
<script type="text/javascript" src="/live2d/script.js"></script> | ||
<canvas id="${config.id}" width="${config.width}" height="${config.height}" class="${config.className}"></canvas> | ||
<style> | ||
#${config.id} { | ||
position: fixed; | ||
right: 0px; | ||
${config.position}: ${config.horizontalOffset}px; | ||
z-index: 999; | ||
pointer-events: none; | ||
bottom: ${config.bottom}px; | ||
bottom: ${config.bottomOffset}px; | ||
} | ||
</style> | ||
<script>loadlive2d(${JSON.stringify(config.id)} ,${JSON.stringify(url.resolve("/live2d/assets/",models[config.model]))},0.5)</script> | ||
<script src="live2d/device.min.js"></script> | ||
<script type="text/javascript"> | ||
(function(){ | ||
if(device.mobile()){ | ||
if(${config.mobileShow}){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 常见作者的pr“3.0” |
||
document.getElementById("${config.id}").width = ${config.mobileWidth}; | ||
document.getElementById("${config.id}").height = ${config.mobileHeight}; | ||
document.write('<script type="text/javascript" src="/live2d/script.js"><\\/script>'); | ||
document.write('<script>loadlive2d(${JSON.stringify(config.id)}, ${JSON.stringify(url.resolve("/live2d/assets/", config.model + ".model.json"))}, 0.5)<\\/script>'); | ||
} | ||
}else{ | ||
document.write('<script type="text/javascript" src="/live2d/script.js"><\\/script>'); | ||
document.write('<script>loadlive2d(${JSON.stringify(config.id)}, ${JSON.stringify(url.resolve("/live2d/assets/", config.model + ".model.json"))}, 0.5)<\\/script>'); | ||
} | ||
})(); | ||
</script> | ||
` | ||
}); | ||
}); | ||
|
||
|
||
var config = Object.assign( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 更好地传递config |
||
{ | ||
model: "z16", | ||
}, | ||
config, | ||
hexo.config.live2d | ||
); | ||
|
||
registerDir('live2d/assets/', path.resolve(__dirname, path.join('./assets/', config.model))); | ||
registerFile('live2d/script.js', path.resolve(__dirname, './dist/bundle.js')); | ||
registerFile('live2d/device.min.js', path.resolve(__dirname, './dist/device.min.js')); | ||
|
||
hexo.extend.generator.register('live2d', function (locals) { | ||
return generators; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nito系列 (i.e.
ni-j
,nico
,nito
,nipsilon
,nietzche
) 都用不了了There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--已查阅并更新
请仔细再次检查确保无误