@@ -73,15 +73,20 @@ hexo.extend.helper.register('live2d', function() {
7373 <script src="/live2d/device.min.js"></script>
7474 <script type="text/javascript">
7575 (function(){
76- if(device.mobile()){
77- ${ config . mobileShow ? `document.getElementById("${ config . id } ").style.width = '${ config . width * config . mobileScaling } px';
78- document.getElementById("${ config . id } ").style.height = '${ config . height * config . mobileScaling } px';
79- document.write('<script type="text/javascript" src="/live2d/script.js"><\\/script>');
80- document.write('<script>loadlive2d(${ JSON . stringify ( config . id ) } , ${ JSON . stringify ( url . resolve ( "/live2d/assets/" , config . model + ".model.json" ) ) } , 0.5)<\\/script>');` : `` }
81- }else{
82- document.write('<script type="text/javascript" src="/live2d/script.js"><\\/script>');
83- document.write('<script>loadlive2d(${ JSON . stringify ( config . id ) } , ${ JSON . stringify ( url . resolve ( "/live2d/assets/" , config . model + ".model.json" ) ) } , 0.5)<\\/script>');
84- }
76+ if(typeof(device) != "undefined"){
77+ if(device.mobile()){
78+ ${ config . mobileShow ? `document.getElementById("${ config . id } ").style.width = '${ config . width * config . mobileScaling } px';
79+ document.getElementById("${ config . id } ").style.height = '${ config . height * config . mobileScaling } px';
80+ document.write('<script type="text/javascript" src="/live2d/script.js"><\\/script>');
81+ document.write('<script>loadlive2d(${ JSON . stringify ( config . id ) } , ${ JSON . stringify ( url . resolve ( "/live2d/assets/" , config . model + ".model.json" ) ) } , 0.5)<\\/script>');` : `` }
82+ }else{
83+ document.write('<script type="text/javascript" src="/live2d/script.js"><\\/script>');
84+ document.write('<script>loadlive2d(${ JSON . stringify ( config . id ) } , ${ JSON . stringify ( url . resolve ( "/live2d/assets/" , config . model + ".model.json" ) ) } , 0.5)<\\/script>');
85+ }
86+ }else{
87+ document.write('<script type="text/javascript" src="/live2d/script.js"><\\/script>');
88+ document.write('<script>loadlive2d(${ JSON . stringify ( config . id ) } , ${ JSON . stringify ( url . resolve ( "/live2d/assets/" , config . model + ".model.json" ) ) } , 0.5)<\\/script>');
89+ }
8590 })();
8691 </script>
8792`
@@ -105,7 +110,7 @@ fs.exists(path.resolve(__dirname, './dist/device.min.js'), function(exists){
105110 if ( exists ) {
106111 registerFile ( 'live2d/device.min.js' , path . resolve ( __dirname , './dist/device.min.js' ) ) ;
107112 } else {
108- console . log ( "live2d serverJs can't find device.js" ) ;
113+ console . log ( "Live2d serverJs: can't find device.js, contant the author for support. " ) ;
109114 return ;
110115 }
111116} ) ;
0 commit comments