diff --git a/packages/core/server/src/locale/locale.ts b/packages/core/server/src/locale/locale.ts index d51aab425..c7cc2d836 100644 --- a/packages/core/server/src/locale/locale.ts +++ b/packages/core/server/src/locale/locale.ts @@ -1,7 +1,6 @@ import { Cache, createCache } from '@nocobase/cache'; import { lodash } from '@nocobase/utils'; import Application from '../application'; -import { PluginManager } from '../plugin-manager'; import { getResource } from './resource'; export class Locale { @@ -67,7 +66,14 @@ export class Locale { const names = this.app.pm.getAliases(); for (const name of names) { try { - const packageName = PluginManager.getPackageName(name); + const p = this.app.pm.get(name); + if (!p) { + continue; + } + const packageName = p.options?.packageName; + if (!packageName) { + continue; + } // this.app.log.debug(`load [${packageName}] locale resource `); // this.app.setMaintainingMessage(`load [${packageName}] locale resource `); const res = getResource(packageName, lang); diff --git a/packages/plugins/@nocobase/plugin-api-doc/src/server/swagger/loader.ts b/packages/plugins/@nocobase/plugin-api-doc/src/server/swagger/loader.ts index 492e9064e..bb81d941d 100644 --- a/packages/plugins/@nocobase/plugin-api-doc/src/server/swagger/loader.ts +++ b/packages/plugins/@nocobase/plugin-api-doc/src/server/swagger/loader.ts @@ -1,4 +1,3 @@ -import { PluginManager } from '@nocobase/server'; import { requireModule } from '@nocobase/utils'; import { merge } from './merge'; @@ -30,7 +29,10 @@ export const getPluginsSwagger = async (db: any, pluginNames?: string[]) => { }); const swaggers = {}; for (const plugin of plugins) { - const packageName = PluginManager.getPackageName(plugin.get('name')); + const packageName = plugin.get('packageName'); + if (!packageName) { + continue; + } const res = loadSwagger(packageName); if (Object.keys(res).length) { swaggers[plugin.get('name')] = res; diff --git a/packages/plugins/@nocobase/plugin-client/src/server/server.ts b/packages/plugins/@nocobase/plugin-client/src/server/server.ts index 590da0d34..4b4608c2f 100644 --- a/packages/plugins/@nocobase/plugin-client/src/server/server.ts +++ b/packages/plugins/@nocobase/plugin-client/src/server/server.ts @@ -1,4 +1,4 @@ -import { Plugin, PluginManager, getExposeUrl } from '@nocobase/server'; +import { Plugin } from '@nocobase/server'; import fs from 'fs'; import { resolve } from 'path'; import { getAntdLocale } from './antd'; @@ -69,7 +69,6 @@ export class ClientPlugin extends Plugin { }); this.app.acl.allow('app', 'getLang'); this.app.acl.allow('app', 'getInfo'); - this.app.acl.allow('app', 'getPlugins'); this.app.acl.allow('plugins', '*', 'public'); this.app.acl.registerSnippet({ name: 'app', @@ -115,30 +114,6 @@ export class ClientPlugin extends Plugin { }; await next(); }, - async getPlugins(ctx, next) { - const pm = ctx.db.getRepository('applicationPlugins'); - const PLUGIN_CLIENT_ENTRY_FILE = 'dist/client/index.js'; - const items = await pm.find({ - filter: { - enabled: true, - }, - }); - ctx.body = items - .map((item) => { - try { - const packageName = PluginManager.getPackageName(item.name); - return { - ...item.toJSON(), - packageName, - url: getExposeUrl(packageName, PLUGIN_CLIENT_ENTRY_FILE), - }; - } catch { - return false; - } - }) - .filter(Boolean); - await next(); - }, async clearCache(ctx, next) { await ctx.cache.reset(); await next();