144 lines
8.3 KiB
JavaScript
144 lines
8.3 KiB
JavaScript
export const smsSchema = {
|
|
key: 'users.sms',
|
|
title: '短信接口',
|
|
icon: 'fa fas fa-comment',
|
|
description: '配置短信验证码和短信通知服务的供应商、模板和限流策略。',
|
|
defaults: {
|
|
sms_enabled: false,
|
|
sms_provider: 'aliyun',
|
|
sms_number_limit_ch: true,
|
|
sms_access_key: '',
|
|
sms_access_secret: '',
|
|
sms_sign_name: '',
|
|
sms_template_code: '',
|
|
sms_code_length: 6,
|
|
sms_code_expire: 300,
|
|
sms_rate_limit: 60,
|
|
sms_daily_limit: 10,
|
|
sms_notify_bind: true,
|
|
sms_notify_login: false,
|
|
sms_notify_register: true,
|
|
sms_notify_reset_password: true,
|
|
sms_ali_api_type: 'sms',
|
|
sms_region_id: 'cn-hangzhou',
|
|
sms_tencent_app_id: '',
|
|
sms_tencent_app_key: '',
|
|
sms_tencent_secret_id: '',
|
|
sms_tencent_secret_key: '',
|
|
sms_tencent_region: 'ap-guangzhou',
|
|
sms_huawei_sender: '',
|
|
sms_huawei_signature: '',
|
|
sms_huawei_endpoint: '',
|
|
sms_custom_url: '',
|
|
sms_custom_method: 'POST',
|
|
sms_custom_auth_type: 'header',
|
|
sms_custom_auth_key: '',
|
|
sms_custom_auth_value: '',
|
|
sms_custom_headers: '',
|
|
sms_custom_body: '',
|
|
sms_custom_success_rule: '',
|
|
},
|
|
groups: [
|
|
{
|
|
key: 'provider',
|
|
title: '供应商配置',
|
|
icon: 'fa fas fa-plug',
|
|
fields: [
|
|
{ key: 'sms_enabled', label: '启用短信服务', type: 'switch', default: false, help: '开启后支持短信验证码和短信通知' },
|
|
{
|
|
key: 'sms_provider',
|
|
label: '短信供应商',
|
|
type: 'select',
|
|
default: 'aliyun',
|
|
options: [
|
|
{ label: '阿里云短信', value: 'aliyun' },
|
|
{ label: '腾讯云短信', value: 'tencent' },
|
|
{ label: '华为云短信', value: 'huawei' },
|
|
{ label: '自定义接口', value: 'custom' },
|
|
],
|
|
dependsOn: { key: 'sms_enabled', value: true },
|
|
},
|
|
{ key: 'sms_number_limit_ch', label: '仅发国内', type: 'switch', default: true, dependsOn: { key: 'sms_enabled', value: true }, help: '开启后仅支持发送国内短信,关闭后可发送港澳台及国际短信' },
|
|
{ key: 'sms_access_key', label: 'AccessKey / SecretId / AppKey', type: 'input', default: '', dependsOn: { key: 'sms_enabled', value: true }, help: '阿里云填 AccessKey,腾讯云填 SecretId,华为云填 AppKey' },
|
|
{ key: 'sms_access_secret', label: 'AccessSecret / SecretKey / AppSecret', type: 'input', inputType: 'password', default: '', dependsOn: { key: 'sms_enabled', value: true } },
|
|
],
|
|
},
|
|
{
|
|
key: 'aliyun',
|
|
title: '阿里云配置',
|
|
icon: 'fa fas fa-cloud',
|
|
fields: [
|
|
{ key: 'sms_ali_api_type', label: '接口类型', type: 'radio', default: 'sms', options: [{ label: '短信服务', value: 'sms' }, { label: '号码认证', value: 'verify' }], dependsOn: { key: 'sms_provider', value: 'aliyun' } },
|
|
{ key: 'sms_region_id', label: 'RegionId', type: 'input', default: 'cn-hangzhou', dependsOn: { key: 'sms_provider', value: 'aliyun' } },
|
|
],
|
|
},
|
|
{
|
|
key: 'tencent',
|
|
title: '腾讯云配置',
|
|
icon: 'fa fas fa-cloud',
|
|
fields: [
|
|
{ key: 'sms_tencent_app_id', label: 'SdkAppId', type: 'input', default: '', dependsOn: { key: 'sms_provider', value: 'tencent' }, help: '腾讯云短信应用 ID' },
|
|
{ key: 'sms_tencent_app_key', label: 'AppKey', type: 'input', inputType: 'password', default: '', dependsOn: { key: 'sms_provider', value: 'tencent' } },
|
|
{ key: 'sms_tencent_secret_id', label: 'SecretId', type: 'input', default: '', dependsOn: { key: 'sms_provider', value: 'tencent' } },
|
|
{ key: 'sms_tencent_secret_key', label: 'SecretKey', type: 'input', inputType: 'password', default: '', dependsOn: { key: 'sms_provider', value: 'tencent' } },
|
|
{ key: 'sms_tencent_region', label: '地域', type: 'input', default: 'ap-guangzhou', dependsOn: { key: 'sms_provider', value: 'tencent' } },
|
|
],
|
|
},
|
|
{
|
|
key: 'huawei',
|
|
title: '华为云配置',
|
|
icon: 'fa fas fa-cloud',
|
|
fields: [
|
|
{ key: 'sms_huawei_sender', label: '通道号 (sender)', type: 'input', default: '', dependsOn: { key: 'sms_provider', value: 'huawei' } },
|
|
{ key: 'sms_huawei_signature', label: '短信签名', type: 'input', default: '', dependsOn: { key: 'sms_provider', value: 'huawei' }, help: '华为云短信签名内容' },
|
|
{ key: 'sms_huawei_endpoint', label: 'API Endpoint', type: 'input', default: '', dependsOn: { key: 'sms_provider', value: 'huawei' }, help: '留空使用默认 endpoint' },
|
|
],
|
|
},
|
|
{
|
|
key: 'custom',
|
|
title: '自定义接口配置',
|
|
icon: 'fa fas fa-plug',
|
|
fields: [
|
|
{ key: 'sms_custom_url', label: '请求 URL', type: 'input', default: '', dependsOn: { key: 'sms_provider', value: 'custom' }, help: '支持 {phone} {code} {time} 变量' },
|
|
{ key: 'sms_custom_method', label: '请求方法', type: 'select', default: 'POST', options: [{ label: 'POST', value: 'POST' }, { label: 'GET', value: 'GET' }, { label: 'PUT', value: 'PUT' }], dependsOn: { key: 'sms_provider', value: 'custom' } },
|
|
{ key: 'sms_custom_auth_type', label: '鉴权方式', type: 'select', default: 'header', options: [{ label: 'Header', value: 'header' }], dependsOn: { key: 'sms_provider', value: 'custom' } },
|
|
{ key: 'sms_custom_auth_key', label: '鉴权 Header 名', type: 'input', default: '', dependsOn: { key: 'sms_provider', value: 'custom' } },
|
|
{ key: 'sms_custom_auth_value', label: '鉴权 Header 值', type: 'input', inputType: 'password', default: '', dependsOn: { key: 'sms_provider', value: 'custom' }, help: '支持 {phone} {code} {time} 变量' },
|
|
{ key: 'sms_custom_headers', label: '自定义 Headers', type: 'textarea', default: '', dependsOn: { key: 'sms_provider', value: 'custom' }, help: '每行一个,格式:Key: Value' },
|
|
{ key: 'sms_custom_body', label: '请求 Body', type: 'textarea', default: '', dependsOn: { key: 'sms_provider', value: 'custom' }, help: 'JSON 格式,支持 {phone} {code} {time} 变量' },
|
|
{ key: 'sms_custom_success_rule', label: '成功判定规则', type: 'input', default: '', dependsOn: { key: 'sms_provider', value: 'custom' }, help: '格式:status:200 或 json:code=0 或 contains:success' },
|
|
],
|
|
},
|
|
{
|
|
key: 'template',
|
|
title: '短信模板',
|
|
icon: 'fa fas fa-comment',
|
|
fields: [
|
|
{ key: 'sms_sign_name', label: '短信签名', type: 'input', default: '', dependsOn: { key: 'sms_enabled', value: true }, help: '在短信服务商申请的短信签名(所有供应商共用此字段)' },
|
|
{ key: 'sms_template_code', label: '验证码模板 ID', type: 'input', default: '', dependsOn: { key: 'sms_enabled', value: true }, help: '所有供应商共用此模板 ID' },
|
|
{ key: 'sms_code_length', label: '验证码长度', type: 'number', default: 6, min: 4, max: 8, dependsOn: { key: 'sms_enabled', value: true } },
|
|
{ key: 'sms_code_expire', label: '验证码有效期 (秒)', type: 'number', default: 300, min: 60, max: 600, dependsOn: { key: 'sms_enabled', value: true } },
|
|
],
|
|
},
|
|
{
|
|
key: 'rate_limit',
|
|
title: '限流策略',
|
|
icon: 'fa fas fa-shield-alt',
|
|
fields: [
|
|
{ key: 'sms_rate_limit', label: '发送间隔 (秒)', type: 'number', default: 60, min: 10, max: 300, dependsOn: { key: 'sms_enabled', value: true }, help: '同一手机号两次发送的最小间隔' },
|
|
{ key: 'sms_daily_limit', label: '每日发送上限', type: 'number', default: 10, min: 1, max: 100, dependsOn: { key: 'sms_enabled', value: true }, help: '同一手机号每天最多发送条数' },
|
|
],
|
|
},
|
|
{
|
|
key: 'triggers',
|
|
title: '通知场景',
|
|
icon: 'fa fas fa-bell',
|
|
fields: [
|
|
{ key: 'sms_notify_bind', label: '绑定手机时验证', type: 'switch', default: true, dependsOn: { key: 'sms_enabled', value: true } },
|
|
{ key: 'sms_notify_login', label: '短信登录', type: 'switch', default: false, dependsOn: { key: 'sms_enabled', value: true } },
|
|
{ key: 'sms_notify_register', label: '注册验证', type: 'switch', default: true, dependsOn: { key: 'sms_enabled', value: true } },
|
|
{ key: 'sms_notify_reset_password', label: '找回密码', type: 'switch', default: true, dependsOn: { key: 'sms_enabled', value: true } },
|
|
],
|
|
},
|
|
],
|
|
} |