From f64ff8341483041bdc60ab239309d44365a64e00 Mon Sep 17 00:00:00 2001 From: whyour Date: Sun, 4 Jun 2023 22:11:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=88=97=E8=A1=A8=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=AD=97=E7=AC=A6=E8=BD=AC=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/services/cron.ts | 22 +++++++++------------- back/services/dependence.ts | 18 ++++++++---------- back/services/env.ts | 2 +- back/services/open.ts | 2 +- back/services/subscription.ts | 19 +++++++------------ 5 files changed, 26 insertions(+), 37 deletions(-) diff --git a/back/services/cron.ts b/back/services/cron.ts index 5a412fed..36853e29 100644 --- a/back/services/cron.ts +++ b/back/services/cron.ts @@ -21,7 +21,7 @@ import { spawn } from 'cross-spawn'; @Service() export default class CronService { - constructor(@Inject('logger') private logger: winston.Logger) { } + constructor(@Inject('logger') private logger: winston.Logger) {} private isSixCron(cron: Crontab) { const { schedule } = cron; @@ -194,17 +194,13 @@ export default class CronService { { [operate2]: [ { [operate]: `%${value}%` }, - { [operate]: `%${encodeURIComponent(value)}%` }, + { [operate]: `%${encodeURI(value)}%` }, ], }, { [operate2]: [ where(colFn(property), operate, `%${value}%`), - where( - colFn(property), - operate, - `%${encodeURIComponent(value)}%`, - ), + where(colFn(property), operate, `%${encodeURI(value)}%`), ], }, ], @@ -231,7 +227,7 @@ export default class CronService { q[column] = { [Op.or]: [ { [Op.like]: `%${textArray[1]}%` }, - { [Op.like]: `%${encodeURIComponent(textArray[1])}%` }, + { [Op.like]: `%${encodeURI(textArray[1])}%` }, ], }; break; @@ -239,7 +235,7 @@ export default class CronService { const reg = { [Op.or]: [ { [Op.like]: `%${searchText}%` }, - { [Op.like]: `%${encodeURIComponent(searchText)}%` }, + { [Op.like]: `%${encodeURI(searchText)}%` }, ], }; q[Op.or] = [ @@ -367,9 +363,9 @@ export default class CronService { { status: CrontabStatus.queued }, { where: { id: ids } }, ); - ids.forEach(id => { - this.runSingle(id) - }) + ids.forEach((id) => { + this.runSingle(id); + }); } public async stop(ids: number[]) { @@ -451,7 +447,7 @@ export default class CronService { resolve(); }); }); - }) + }); } public async disabled(ids: number[]) { diff --git a/back/services/dependence.ts b/back/services/dependence.ts index 7b8bd1c9..b0c05c1d 100644 --- a/back/services/dependence.ts +++ b/back/services/dependence.ts @@ -21,7 +21,7 @@ export default class DependenceService { constructor( @Inject('logger') private logger: winston.Logger, private sockService: SockService, - ) { } + ) {} public async create(payloads: Dependence[]): Promise { const tabs = payloads.map((x) => { @@ -79,7 +79,7 @@ export default class DependenceService { ): Promise { let condition = { ...query, type: DependenceTypes[type as any] }; if (searchValue) { - const encodeText = encodeURIComponent(searchValue); + const encodeText = encodeURI(searchValue); const reg = { [Op.or]: [ { [Op.like]: `%${searchValue}%` }, @@ -106,12 +106,8 @@ export default class DependenceService { force: boolean = false, ) { docs.forEach((dep) => { - this.installOrUninstallDependencies( - [dep], - isInstall, - force, - ) - }) + this.installOrUninstallDependencies([dep], isInstall, force); + }); } public async reInstall(ids: number[]): Promise { @@ -186,7 +182,9 @@ export default class DependenceService { }); await this.updateLog(depIds, message); - const cp = spawn(`${depRunCommand} ${depNames}`, { shell: '/bin/bash' }); + const cp = spawn(`${depRunCommand} ${depNames}`, { + shell: '/bin/bash', + }); cp.stdout.on('data', async (data) => { this.sockService.sendMessage({ @@ -250,6 +248,6 @@ export default class DependenceService { resolve(null); }); }); - }) + }); } } diff --git a/back/services/env.ts b/back/services/env.ts index c96ca883..ca7e6236 100644 --- a/back/services/env.ts +++ b/back/services/env.ts @@ -121,7 +121,7 @@ export default class EnvService { public async envs(searchText: string = '', query: any = {}): Promise { let condition = { ...query }; if (searchText) { - const encodeText = encodeURIComponent(searchText); + const encodeText = encodeURI(searchText); const reg = { [Op.or]: [ { [Op.like]: `%${searchText}%` }, diff --git a/back/services/open.ts b/back/services/open.ts index c92d6f24..e9f97ce5 100644 --- a/back/services/open.ts +++ b/back/services/open.ts @@ -75,7 +75,7 @@ export default class OpenService { ): Promise { let condition = { ...query }; if (searchText) { - const encodeText = encodeURIComponent(searchText); + const encodeText = encodeURI(searchText); const reg = { [Op.or]: [ { [Op.like]: `%${searchText}%` }, diff --git a/back/services/subscription.ts b/back/services/subscription.ts index 925a7018..b98937fc 100644 --- a/back/services/subscription.ts +++ b/back/services/subscription.ts @@ -6,9 +6,7 @@ import { SubscriptionModel, SubscriptionStatus, } from '../data/subscription'; -import { - ChildProcessWithoutNullStreams, -} from 'child_process'; +import { ChildProcessWithoutNullStreams } from 'child_process'; import fs from 'fs'; import { getFileContentByName, @@ -37,7 +35,7 @@ export default class SubscriptionService { private scheduleService: ScheduleService, private sockService: SockService, private sshKeyService: SshKeyService, - ) { } + ) {} public async list(searchText?: string): Promise { let query = {}; @@ -45,7 +43,7 @@ export default class SubscriptionService { const reg = { [Op.or]: [ { [Op.like]: `%${searchText}%` }, - { [Op.like]: `%${encodeURIComponent(searchText)}%` }, + { [Op.like]: `%${encodeURI(searchText)}%` }, ], }; query = { @@ -276,9 +274,9 @@ export default class SubscriptionService { { status: SubscriptionStatus.queued }, { where: { id: ids } }, ); - ids.forEach(id => { - this.runSingle(id) - }) + ids.forEach((id) => { + this.runSingle(id); + }); } public async stop(ids: number[]) { @@ -315,10 +313,7 @@ export default class SubscriptionService { const command = formatCommand(subscription); - this.scheduleService.runTask( - command, - this.taskCallbacks(subscription), - ); + this.scheduleService.runTask(command, this.taskCallbacks(subscription)); } public async disabled(ids: number[]) {