perf: 1panel支持先上传证书再选择证书

This commit is contained in:
xiaojunnuo
2026-04-10 00:08:10 +08:00
parent a7a4f66633
commit 7a9eec88e8
10 changed files with 197 additions and 5 deletions
@@ -2,7 +2,7 @@ import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput
import { CertApplyPluginNames, CertInfo } from "@certd/plugin-cert";
import { OnePanelAccess } from "../access.js";
import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine } from "@certd/plugin-lib";
import { createCertDomainGetterInputDefine, createRemoteSelectInputDefine, ICertInfoGetter } from "@certd/plugin-lib";
import { OnePanelClient } from "../client.js";
@IsTaskPlugin({
@@ -66,6 +66,7 @@ export class OnePanelDeployToWebsitePlugin extends AbstractTaskPlugin {
watches: ["accessId"],
helper: "要更新的1Panel证书id,选择授权之后,从下拉框中选择\nIP需要加白名单,如果是同一台机器部署的,可以试试172.16.0.0/12",
required: true,
uploadCert: {}
})
)
sslIds!: string[];
@@ -213,5 +214,36 @@ export class OnePanelDeployToWebsitePlugin extends AbstractTaskPlugin {
});
return this.ctx.utils.options.buildGroupOptions(list, this.certDomains);
}
async onUploadCert(data: { pipelineId: string, certName: string }) {
if (!this.access) {
throw new Error("请先选择1panel授权");
}
const certInfoGetter = await this.ctx.serviceGetter.get<ICertInfoGetter>("certInfoGetter")
const cert = await certInfoGetter.getByPipelineId(Number(data.pipelineId));
const client = new OnePanelClient({
access: this.access,
http: this.http,
logger: this.logger,
utils: this.ctx.utils,
});
await client.doRequest({
url: `/api/${this.access.apiVersion}/websites/ssl/upload`,
method: "post",
data: {
sslId: 0,
certificate: cert.crt,
certificatePath: "",
description: data.certName,
privateKey: cert.key,
privateKeyPath: "",
type: "paste",
},
currentNode: this.currentNode,
});
}
}
new OnePanelDeployToWebsitePlugin();