refactor(nginx-proxy-manager): 替换直接动态导入为运行时依赖导入

将插件中直接使用的动态导入改为通过runtimeDepsService统一处理,同时重构导入方式为runtimeImport变量,移除冗余的form-data和otplib直接导入,统一导入逻辑
This commit is contained in:
xiaojunnuo
2026-07-12 03:10:52 +08:00
parent 8517a0b564
commit fe09e75b80
2 changed files with 15 additions and 9 deletions
@@ -57,12 +57,12 @@ input:
action: TestRequest
helper: 测试登录并拉取代理主机列表。
content: |
const { BaseAccess } = await import("@certd/pipeline");
const httpsModule = await import("node:https");
const { URL } = await import("node:url");
const axiosModule = await import("axios");
const formDataModule = await import("form-data");
const { authenticator } = await import("otplib");
const runtimeImport = import;
const { BaseAccess } = await runtimeImport("@certd/pipeline");
const httpsModule = await runtimeImport("node:https");
const { URL } = await runtimeImport("node:url");
const axiosModule = await runtimeImport("axios");
const formDataModule = await runtimeImport("form-data");
const https = httpsModule.default ?? httpsModule;
const axios = axiosModule.default ?? axiosModule;
@@ -114,6 +114,7 @@ content: |
class NginxProxyManagerClient {
constructor(options) {
this.options = options;
this.importFn = options.importFn;
this.endpoint = normalizeEndpoint(options.endpoint);
this.apiBaseUrl = `${this.endpoint}/api`;
this.token = undefined;
@@ -267,6 +268,7 @@ content: |
let code;
try {
const { authenticator } = await this.importFn("otplib");
code = authenticator.generate(this.options.totpSecret);
} catch (error) {
throw describeError(error, "Generating TOTP code");
@@ -327,6 +329,7 @@ content: |
password: this.password,
totpSecret: this.totpSecret || undefined,
ignoreTls: this.ignoreTls === true,
importFn: this.importRuntime.bind(this),
});
}