From ba3c12b1b01378e906b0bd5918ea5a4c0c3f92b3 Mon Sep 17 00:00:00 2001 From: SmallK111407 <3399280843@qq.com> Date: Mon, 11 Sep 2023 23:35:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E6=BB=9Aloader.js=EF=BC=8Cbug:=20?= =?UTF-8?q?=E6=AD=A4=E5=86=99=E6=B3=95=E4=BC=9A=E5=AF=BC=E8=87=B4=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=8F=92=E4=BB=B6=E5=86=99=E6=B3=95=E4=B8=8D=E8=A7=84?= =?UTF-8?q?=E8=8C=83=E4=BB=8E=E8=80=8C=E5=AF=BC=E8=87=B4=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/plugins/loader.js | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/lib/plugins/loader.js b/lib/plugins/loader.js index b96f90e..83ebb71 100644 --- a/lib/plugins/loader.js +++ b/lib/plugins/loader.js @@ -52,28 +52,10 @@ class PluginsLoader { let pluCount = 0 let packageErr = [] - for (let File of files) - { - let { name: appName, path: appPath } = File + for (let File of files) { try { let tmp = await import(File.path) - // 如果当前是一个插件 - if (tmp.apps) { - // 插件主目录,在这里this.watch里已经做了判断所以不用捕获异常 - appName = `${appName}/apps` - // 插件路径 - appPath = appPath.replace(/\/index\.js$/, ""); - // 逐个遍历插件app里的js - for (let app in tmp.apps) { - // 插件目录的功能 - const curPlugin = tmp.apps[app] - // 当前目录的功能名 (apps/hello.js) - const curAppName = curPlugin.name - // 监听插件 - this.watch(appName, `${curAppName}.js`) - } - tmp = { ...tmp.apps } - } + if (tmp.apps) tmp = { ...tmp.apps } let isAdd = false lodash.forEach(tmp, (p, i) => { if (!p.prototype) return @@ -87,7 +69,7 @@ class PluginsLoader { this.collectTask(plugin.task) this.priority.push({ class: p, - key: `${appName}/${p.name}.js`, + key: File.name, name: plugin.name, priority: plugin.priority }) @@ -791,9 +773,6 @@ class PluginsLoader { if (this.priority[i].key == key) { this.priority[i].class = p this.priority[i].priority = plugin.priority - // 插件更新 (ps.如果不写无法更新插件,只能更新example) - this.watcher[`${dirName}.${appName}`] = watcher - break; } } })