From 96e252abc622c38b88870c992dbdd0e1bd0a408b Mon Sep 17 00:00:00 2001 From: Kenny <27463495+Frontesque@users.noreply.github.com> Date: Tue, 12 Jul 2022 16:05:54 -0400 Subject: [PATCH] feat: :sparkles: More Plugin Stuff --- NUXT/pages/mods/plugins.vue | 85 +++++++++----------------- NUXT/plugins/thirdPartyPluginLoader.js | 13 ++++ 2 files changed, 42 insertions(+), 56 deletions(-) diff --git a/NUXT/pages/mods/plugins.vue b/NUXT/pages/mods/plugins.vue index 182a055..15650aa 100644 --- a/NUXT/pages/mods/plugins.vue +++ b/NUXT/pages/mods/plugins.vue @@ -1,10 +1,10 @@ @@ -82,19 +53,21 @@ export default { const file = document.getElementById("filePicker").files[0]; const contents = await vm.readFileContent(file); await vm.$tppl.addPlugin(contents); + this.rebuildList(); }; - this.plugins = this.$tppl.list; - console.log(this.plugins) + this.rebuildList(); + }, methods: { - readFileContent(file) { - const reader = new FileReader(); - return new Promise((resolve, reject) => { - reader.onload = (event) => resolve(event.target.result); - reader.onerror = (error) => reject(error); - reader.readAsText(file); - }); + async rebuildList() { + const pluginsData = await this.$tppl.list; + this.plugins = pluginsData.files; + }, + + async remove(plugin) { + await this.$tppl.removePlugin(plugin); + this.rebuildList(); }, pickFile() { diff --git a/NUXT/plugins/thirdPartyPluginLoader.js b/NUXT/plugins/thirdPartyPluginLoader.js index 001807d..f4fe9ea 100644 --- a/NUXT/plugins/thirdPartyPluginLoader.js +++ b/NUXT/plugins/thirdPartyPluginLoader.js @@ -50,8 +50,21 @@ const module = { data: content, encoding: Encoding.UTF8, }); + resolve(); }); }, + + async removePlugin(name) { + await ensureStructure; + new Promise(async (resolve, reject) => { + await Filesystem.deleteFile({ + path: fs.plugins + name, + directory: APP_DIRECTORY, + }); + resolve(); + }); + }, + }; //--- Start ---//