From 5851ed82d524854360d88f121c84ba4af23d4462 Mon Sep 17 00:00:00 2001 From: filesite Date: Wed, 5 Jun 2024 07:26:06 +0800 Subject: [PATCH] improve config get --- router_aliyun.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/router_aliyun.js b/router_aliyun.js index fd0070e..016cc7e 100644 --- a/router_aliyun.js +++ b/router_aliyun.js @@ -10,10 +10,10 @@ const {default: common} = require('./common.js'); const {default: aliyunSmsClient} = require('./aliyunSmsClient'); const {default: defaultConfig, getCustomConfigs: getCustomConfigs} = require('./conf/config'); - - const router = express.Router(); +let customConfig = null; + //发送注册验证码短信接口 /** * @phoneNumber: 手机号码 @@ -28,7 +28,6 @@ router.post('/sendverifycode', async (req, res) => { let sign = req.body.sign; let data = {code: 0, message: ''}; - let myConfig = await getCustomConfigs('./conf/custom_config.json'); if (!phoneNumber || !codeNumber || !sign) { data.message = '参数不能为空'; @@ -37,6 +36,17 @@ router.post('/sendverifycode', async (req, res) => { }else if (common.isVerifyCode(codeNumber) == false) { data.message = '验证码格式错误,必须是4位数的数字'; }else { + //使用默认配置 + let myConfig = defaultConfig; + + //加载自定义配置 + if (!customConfig) { + customConfig = await getCustomConfigs('./conf/custom_config.json'); + } + + //使用自定义配置 + myConfig = customConfig; + let paramsCheck = {}; for (const key in req.body) { if (key != 'sign') {