mirror of
https://github.com/certd/certd.git
synced 2026-07-18 03:57:31 +08:00
fix: 修复上传到cos报runtimeDepsService未初始化的问题
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { TencentAccess } from "../../../plugins/plugin-lib/tencent/access.js";
|
||||
import { ISmsService, PluginInputs, SmsPluginCtx } from "./api.js";
|
||||
import { TencentAccess } from "../../../plugins/plugin-lib/tencent/access.js";
|
||||
import { importRuntime } from "@certd/pipeline";
|
||||
import { ISmsService, PluginInputs } from "./api.js";
|
||||
|
||||
export type TencentSmsConfig = {
|
||||
accessId: string;
|
||||
@@ -66,26 +67,16 @@ export class TencentSmsService implements ISmsService {
|
||||
};
|
||||
}
|
||||
|
||||
ctx: SmsPluginCtx<TencentSmsConfig>;
|
||||
ctx: { accessService: any; config: TencentSmsConfig };
|
||||
|
||||
async setCtx(ctx: any) {
|
||||
this.ctx = ctx;
|
||||
if (this.ctx.runtimeDepsService) {
|
||||
await this.ctx.runtimeDepsService.ensureDependencies({
|
||||
dependencies: {
|
||||
"tencentcloud-sdk-nodejs": "^4.1.112",
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async getClient() {
|
||||
if (!this.ctx.runtimeDepsService) {
|
||||
throw new Error("动态依赖服务未初始化,无法加载腾讯云短信SDK");
|
||||
}
|
||||
const sdk = await this.ctx.runtimeDepsService.importRuntime("tencentcloud-sdk-nodejs/tencentcloud/services/sms/v20210111/index.js");
|
||||
const sdk = await importRuntime("tencentcloud-sdk-nodejs/tencentcloud/services/sms/v20210111/index.js");
|
||||
const client = sdk.v20210111.Client;
|
||||
const access = await this.ctx.accessService.getById<TencentAccess>(this.ctx.config.accessId);
|
||||
const access: TencentAccess = await this.ctx.accessService.getById(this.ctx.config.accessId);
|
||||
|
||||
// const region = this.region;
|
||||
const clientConfig = {
|
||||
@@ -126,3 +117,5 @@ export class TencentSmsService implements ISmsService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user