From 5c2bbc941fb39be61500d2d24c4aa783204be0f1 Mon Sep 17 00:00:00 2001 From: hanhh <18330117883@163.com> Date: Sat, 3 Jul 2021 16:49:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8E=B7=E5=8F=96sample?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/api/config.ts | 13 ++++++++++--- back/config/index.ts | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/back/api/config.ts b/back/api/config.ts index 9da30007..175478a2 100644 --- a/back/api/config.ts +++ b/back/api/config.ts @@ -36,9 +36,16 @@ export default (app: Router) => { async (req: Request, res: Response, next: NextFunction) => { const logger: Logger = Container.get('logger'); try { - const content = getFileContentByName( - `${config.configPath}${req.params.file}`, - ); + let content = ''; + if (req.params.file.includes('sample')) { + content = getFileContentByName( + `${config.samplePath}${req.params.file}`, + ); + } else { + content = getFileContentByName( + `${config.configPath}${req.params.file}`, + ); + } res.send({ code: 200, data: content }); } catch (e) { logger.error('🔥 error: %o', e); diff --git a/back/config/index.ts b/back/config/index.ts index 44053157..96bee0b4 100644 --- a/back/config/index.ts +++ b/back/config/index.ts @@ -15,6 +15,7 @@ const authConfigFile = path.join(rootPath, 'config/auth.json'); const extraFile = path.join(rootPath, 'config/extra.sh'); const configPath = path.join(rootPath, 'config/'); const scriptPath = path.join(rootPath, 'scripts/'); +const samplePath = path.join(rootPath, 'sample/'); const logPath = path.join(rootPath, 'log/'); const authError = '错误的用户名密码,请重试'; const loginFaild = '请先登录!'; @@ -58,5 +59,6 @@ export default { envDbFile, configPath, scriptPath, + samplePath, blackFileList: ['auth.json', 'config.sh.sample', 'cookie.sh', 'crontab.list'], };