@@ -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