Merge pull request #684 from universe-st/PR-Branch
新增函数,可以在某扩展加载后调用一段方法
This commit is contained in:
commit
ca5fa929c8
13
game/game.js
13
game/game.js
|
@ -40690,6 +40690,19 @@ new Promise(resolve=>{
|
|||
return extensionName !== void 0 && _status.extensionLoaded.includes(extensionName);
|
||||
},
|
||||
|
||||
runAfterExtensionLoaded(extensionName,runnable) {
|
||||
if(game.hasExtensionLoaded(extensionName)){
|
||||
runnable();
|
||||
}else{
|
||||
let eventName = `Noname.Init.Extension.${extensionName}.onLoad`;
|
||||
let callback = ()=>{
|
||||
lib.announce.unsubscribe(eventName,callback);
|
||||
runnable();
|
||||
};
|
||||
lib.announce.subscribe(eventName,callback);
|
||||
}
|
||||
},
|
||||
|
||||
removeExtension:(extensionName,keepFile)=>{
|
||||
const prefix=`extension_${extensionName}`;
|
||||
Object.keys(lib.config).forEach(key=>{
|
||||
|
|
Loading…
Reference in New Issue