#扩展短信服务商
本文主要介绍如何通过插件的形式扩展 验证:短信 功能中的短信服务商。
#客户端
#注册配置表单
用户在配置短信验证器时,选择短信服务商类型后,会出现一个和该服务商类型关联的配置表单,这个配置表单需要开发者在客户端自行注册。

import { Plugin, SchemaComponent } from '@nocobase/client';
import PluginVerificationClient from '@nocobase/plugin-verification/client';
import React from 'react';
const CustomSMSProviderSettingsForm: React.FC = () => {
return <SchemaComponent schema={{
type: 'void',
properties: {
accessKeyId: {
title: `{{t("Access Key ID", { ns: "${NAMESPACE}" })}}`,
type: 'string',
'x-decorator': 'FormItem',
'x-component': 'TextAreaWithGlobalScope',
required: true,
},
accessKeySecret: {
title: `{{t("Access Key Secret", { ns: "${NAMESPACE}" })}}`,
type: 'string',
'x-decorator': 'FormItem',
'x-component': 'TextAreaWithGlobalScope',
'x-component-props': { password: true },
required: true,
},
}
}} />
}
class PluginCustomSMSProviderClient extends Plugin {
async load() {
const plugin = this.app.pm.get('verification') as PluginVerificationClient;
plugin.smsOTPProviderManager.registerProvider('custom-sms-provider-name', {
components: {
AdminSettingsForm: CustomSMSProviderSettingsForm,
},
});
}
}
