From c28bfe947fc230f5e6e0a678db46de9b1ab037c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=89=E8=8F=9C?= <1659488338@qq.com> Date: Sat, 8 Feb 2025 21:17:21 +0800 Subject: [PATCH] fix: load plugin --- core/src/plugin.ts | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/core/src/plugin.ts b/core/src/plugin.ts index 48e3c3ac..138b3621 100644 --- a/core/src/plugin.ts +++ b/core/src/plugin.ts @@ -289,13 +289,11 @@ export namespace Plugin { export type InstallFn = (plugin: Plugin) => void; export function createIdByPath(filePath: string) { return filePath - .replace(path.resolve(WORK_DIR, 'node_modules', '@zhinjs'), '官方插件') - .replace(path.resolve(WORK_DIR, 'node_modules', 'zhin', 'plugins'), '内置插件') - .replace(path.resolve(WORK_DIR, 'node_modules'), '') - .replace(path.resolve(WORK_DIR, 'plugins'), '自定义插件') + .replace(path.resolve(WORK_DIR, 'node_modules', 'zhin', 'lib', 'plugins') + path.sep, '内置插件') + .replace(path.resolve(WORK_DIR, 'node_modules') + path.sep, '') + .replace(WORK_DIR + path.sep, '') .replace(/((lib)|(src)([\/\\]))?index\.[cm]?[tj]?s$/, ''); } - console.log(createIdByPath(path.join(WORK_DIR, 'node_modules', '@zhinjs/test'))); } export class PluginMap extends Map { @@ -306,10 +304,6 @@ export class PluginMap extends Map { getWithPath(filePath: string) { const id = Plugin.createIdByPath(filePath); if (this.has(id)) return this.get(id); - for (const [_, plugin] of this) { - const result = plugin.filePath.replace(filePath, ''); - if (!result || /^(lib\/)?(index)?\.[cm]?[tj]s$/.test(result)) return plugin; - } } get generateId() {