refactor(core): 重构访问控制和插件实例化逻辑

- 修改访问控制和插件注册方式,使用异步函数统一实例化逻辑
- 更新相关组件和控制器以适应新的异步实例化方式
- 优化 DNS 提供商选择器,增加访问类型支持
This commit is contained in:
xiaojunnuo
2025-04-12 01:21:50 +08:00
parent c4fb138ae8
commit 3d8a5196a0
15 changed files with 79 additions and 39 deletions

View File

@@ -213,10 +213,9 @@ export class PluginService extends BaseService<PluginEntity> {
// const script = await this.compile(plugin.content);
const script = plugin.content
const getPluginClass = new AsyncFunction(script);
const pluginClass = await getPluginClass({ logger: logger });
return new pluginClass();
return await getPluginClass({ logger: logger });
}catch (e) {
logger.error("实例化插件失败:",e)
logger.error("编译插件失败:",e)
throw e
}
@@ -266,8 +265,8 @@ export class PluginService extends BaseService<PluginEntity> {
registry.register(item.name, {
define: item,
target: () => {
return this.getPluginTarget(item.name);
target: async () => {
return await this.getPluginTarget(item.name);
}
});
}