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

Commit 88decdd

Browse files
committed
Improve codes & fix bug
1 parent 6d432b8 commit 88decdd

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

index.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,33 +52,28 @@ hexo.extend.helper.register('live2d', function() {
5252
bottom: ${config.verticalOffset}px;
5353
}
5454
</style>
55-
<script src="live2d/device.min.js"></script>
55+
<script src="/live2d/device.min.js"></script>
5656
<script type="text/javascript">
5757
(function(){
58-
${config.mobileShow ? `
5958
if(device.mobile()){
59+
${config.mobileShow ? `
6060
document.getElementById("${config.id}").width = ${config.mobileWidth};
6161
document.getElementById("${config.id}").height = ${config.mobileHeight};
6262
document.write('<script type="text/javascript" src="/live2d/script.js"><\\/script>');
6363
document.write('<script>loadlive2d(${JSON.stringify(config.id)}, ${JSON.stringify(url.resolve("/live2d/assets/", config.model + ".model.json"))}, 0.5)<\\/script>');
64+
` : ``}
6465
}else{
6566
document.write('<script type="text/javascript" src="/live2d/script.js"><\\/script>');
6667
document.write('<script>loadlive2d(${JSON.stringify(config.id)}, ${JSON.stringify(url.resolve("/live2d/assets/", config.model + ".model.json"))}, 0.5)<\\/script>');
67-
}` : `
68-
if(!device.mobile()){
69-
document.write('<script type="text/javascript" src="/live2d/script.js"><\\/script>');
70-
document.write('<script>loadlive2d(${JSON.stringify(config.id)}, ${JSON.stringify(url.resolve("/live2d/assets/", config.model + ".model.json"))}, 0.5)<\\/script>');
71-
}`
7268
}
7369
})();
7470
</script>
7571
`
7672
});
7773

78-
fs.exists(path.resolve(process.cwd(), path.join('./live2d_models/', config.model)), function(exists){
74+
fs.exists(path.resolve(hexo.base_dir, path.join('./live2d_models/', config.model)), function(exists){
7975
if(exists){
80-
registerDir("live2d/assets/", path.resolve(process.cwd(), path.join('./live2d_models/', config.model)));
81-
console.log('Found custom model at: ' & path.resolve(process.cwd(), path.join('./live2d_models/', config.model)));
76+
registerDir("live2d/assets/", path.resolve(hexo.base_dir, path.join('./live2d_models/', config.model)));
8277
}else{
8378
registerDir('live2d/assets/', path.resolve(__dirname, path.join('./assets/', config.model)));
8479
}

0 commit comments

Comments
 (0)