From 90fe63211d7eb7a688513ce1845d20fe54b7cf24 Mon Sep 17 00:00:00 2001 From: whyour Date: Fri, 28 Jun 2024 20:41:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BF=AE=E6=94=B9=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E7=8A=B6=E6=80=81=E5=8F=AF=E8=83=BD=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/api/env.ts | 3 +++ back/services/cron.ts | 8 +++++++- back/services/user.ts | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/back/api/env.ts b/back/api/env.ts index b916bdc0..845b5df5 100644 --- a/back/api/env.ts +++ b/back/api/env.ts @@ -51,6 +51,9 @@ export default (app: Router) => { const logger: Logger = Container.get('logger'); try { const envService = Container.get(EnvService); + if (!req.body?.length) { + return res.send({ code: 400, message: '参数不正确' }); + } const data = await envService.create(req.body); return res.send({ code: 200, data }); } catch (e) { diff --git a/back/services/cron.ts b/back/services/cron.ts index 3ac3958e..ac941c57 100644 --- a/back/services/cron.ts +++ b/back/services/cron.ts @@ -114,7 +114,13 @@ export default class CronService { } for (const id of ids) { - const cron = await this.getDb({ id }); + let cron; + try { + cron = await this.getDb({ id }); + } catch (err) {} + if (!cron) { + continue; + } if (status === CrontabStatus.idle && log_path !== cron.log_path) { options = omit(options, ['status', 'log_path', 'pid']); } diff --git a/back/services/user.ts b/back/services/user.ts index 80408cc4..94a66047 100644 --- a/back/services/user.ts +++ b/back/services/user.ts @@ -1,6 +1,7 @@ import { Service, Inject } from 'typedi'; import winston from 'winston'; import { + createFile, createRandomString, fileExist, getNetIp, @@ -266,7 +267,7 @@ export default class UserService { public async getUserInfo(): Promise { const authFileExist = await fileExist(config.authConfigFile); if (!authFileExist) { - await fs.writeFile( + await createFile( config.authConfigFile, JSON.stringify({ username: 'admin',