Plugin reloading
This commit is contained in:
parent
1896a0d558
commit
e0df52b6ab
|
@ -116,7 +116,8 @@ export default class {
|
|||
}
|
||||
|
||||
const content = await this.loadContent(paths, configs, readConfig.info, readConfig.main);
|
||||
this.localContent.push(content);
|
||||
if (reload) this.localContent[index] = content;
|
||||
else this.localContent.push(content);
|
||||
return content;
|
||||
|
||||
} catch (err) {
|
||||
|
|
|
@ -52,6 +52,18 @@ export default class extends ContentManager {
|
|||
}
|
||||
}
|
||||
|
||||
static async reloadPlugin(plugin) {
|
||||
const _plugin = plugin instanceof Plugin ? plugin : this.findPlugin(plugin);
|
||||
if (!_plugin) throw { 'message': 'Attempted to reload a plugin that is not loaded?' };
|
||||
if (!_plugin.stop()) throw { 'message': 'Plugin failed to stop!' };
|
||||
const index = this.getPluginIndex(_plugin);
|
||||
const { pluginPath, dirName } = _plugin;
|
||||
|
||||
delete window.require.cache[window.require.resolve(pluginPath)];
|
||||
|
||||
return this.preloadContent(dirName, true, index);
|
||||
}
|
||||
|
||||
static get findPlugin() { return this.findContent }
|
||||
static get getPluginIndex() { return this.getContentIndex }
|
||||
static get getPluginByName() { return this.getContentByName }
|
||||
|
|
|
@ -71,7 +71,16 @@
|
|||
},
|
||||
refreshLocal() { },
|
||||
togglePlugin() { },
|
||||
reloadPlugin() { },
|
||||
reloadPlugin(plugin) {
|
||||
(async () => {
|
||||
try {
|
||||
await this.pluginManager.reloadPlugin(plugin);
|
||||
this.$forceUpdate();
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
})();
|
||||
},
|
||||
showSettings() { }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue