Merge pull request #240 from universe-st/PR-Branch

新增lib.init.addJsForExtension方法
This commit is contained in:
Spmario233 2023-08-27 18:42:39 +08:00 committed by GitHub
commit 04d35b5e90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -7901,6 +7901,9 @@
} }
var loadPack=function(){ var loadPack=function(){
var toLoad=lib.config.all.cards.length+lib.config.all.characters.length+1; var toLoad=lib.config.all.cards.length+lib.config.all.characters.length+1;
if(_status.jsExt){
toLoad += _status.jsExt.length;
}
var packLoaded=function(){ var packLoaded=function(){
toLoad--; toLoad--;
if(toLoad==0){ if(toLoad==0){
@ -7925,6 +7928,11 @@
lib.init.js(lib.assetURL+'card',lib.config.all.cards,packLoaded,packLoaded); lib.init.js(lib.assetURL+'card',lib.config.all.cards,packLoaded,packLoaded);
lib.init.js(lib.assetURL+'character',lib.config.all.characters,packLoaded,packLoaded); lib.init.js(lib.assetURL+'character',lib.config.all.characters,packLoaded,packLoaded);
lib.init.js(lib.assetURL+'character','rank',packLoaded,packLoaded); lib.init.js(lib.assetURL+'character','rank',packLoaded,packLoaded);
if(_status.jsExt){
for(var i=0;i<_status.jsExt.length;i++){
lib.init.js(lib.assetURL+_status.jsExt[i].path,_status.jsExt[i].name,packLoaded,packLoaded);
}
}
// if(lib.device!='ios'&&lib.config.enable_pressure) lib.init.js(lib.assetURL+'game','pressure'); // if(lib.device!='ios'&&lib.config.enable_pressure) lib.init.js(lib.assetURL+'game','pressure');
}; };
@ -9469,6 +9477,13 @@
} }
return style; return style;
}, },
//在扩展的precontent中调用用于加载扩展必需的JS文件。
addJsForExtension:function(path,name){
if(!_status.jsExt){
_status.jsExt = [];
}
_status.jsExt.add({path:path,name:name});
},
js:function(path,file,onload,onerror){ js:function(path,file,onload,onerror){
if(path[path.length-1]=='/'){ if(path[path.length-1]=='/'){
path=path.slice(0,path.length-1); path=path.slice(0,path.length-1);