Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Commit

Permalink
Improve codes & fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazeyu committed Nov 3, 2017
1 parent 6d432b8 commit 88decdd
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,33 +52,28 @@ hexo.extend.helper.register('live2d', function() {
bottom: ${config.verticalOffset}px;
}
</style>
<script src="live2d/device.min.js"></script>
<script src="/live2d/device.min.js"></script>
<script type="text/javascript">
(function(){
${config.mobileShow ? `
if(device.mobile()){
${config.mobileShow ? `
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>');
}` : `
if(!device.mobile()){
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>
`
});

fs.exists(path.resolve(process.cwd(), path.join('./live2d_models/', config.model)), function(exists){
fs.exists(path.resolve(hexo.base_dir, path.join('./live2d_models/', config.model)), function(exists){
if(exists){
registerDir("live2d/assets/", path.resolve(process.cwd(), path.join('./live2d_models/', config.model)));
console.log('Found custom model at: ' & path.resolve(process.cwd(), path.join('./live2d_models/', config.model)));
registerDir("live2d/assets/", path.resolve(hexo.base_dir, path.join('./live2d_models/', config.model)));
}else{
registerDir('live2d/assets/', path.resolve(__dirname, path.join('./assets/', config.model)));
}
Expand Down

0 comments on commit 88decdd

Please sign in to comment.