mirror of
https://github.com/certd/certd.git
synced 2026-07-18 20:17:34 +08:00
feat: 通过插件配置懒加载依赖,动态加载第三方依赖包,精简安装镜像大小
This commit is contained in:
@@ -68,12 +68,20 @@ export class TencentSmsService implements ISmsService {
|
||||
|
||||
ctx: SmsPluginCtx<TencentSmsConfig>;
|
||||
|
||||
setCtx(ctx: any) {
|
||||
async setCtx(ctx: any) {
|
||||
this.ctx = ctx;
|
||||
if (this.ctx.runtimeDepsService) {
|
||||
await this.ctx.runtimeDepsService.ensureDependencies({
|
||||
"tencentcloud-sdk-nodejs": "^4.1.112",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async getClient() {
|
||||
const sdk = await import("tencentcloud-sdk-nodejs/tencentcloud/services/sms/v20210111/index.js");
|
||||
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 client = sdk.v20210111.Client;
|
||||
const access = await this.ctx.accessService.getById<TencentAccess>(this.ctx.config.accessId);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user