From 460a1750f49ff557f3d2dda10b15ed0b1ba4c662 Mon Sep 17 00:00:00 2001 From: whyour Date: Wed, 18 May 2022 23:30:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E8=AE=A2=E9=98=85=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/loaders/initTask.ts | 8 ++++++++ back/services/sshKey.ts | 2 +- back/services/subscription.ts | 2 +- src/pages/crontab/modal.tsx | 2 ++ src/pages/env/modal.tsx | 2 ++ src/pages/subscription/modal.tsx | 15 ++++++++++----- 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/back/loaders/initTask.ts b/back/loaders/initTask.ts index ede7f526..9e486f64 100644 --- a/back/loaders/initTask.ts +++ b/back/loaders/initTask.ts @@ -2,10 +2,12 @@ import { Container } from 'typedi'; import _ from 'lodash'; import SystemService from '../services/system'; import ScheduleService from '../services/schedule'; +import SubscriptionService from '../services/subscription'; export default async () => { const systemService = Container.get(SystemService); const scheduleService = Container.get(ScheduleService); + const subscriptionService = Container.get(SubscriptionService); // 运行删除日志任务 const data = await systemService.getLogRemoveFrequency(); @@ -20,4 +22,10 @@ export default async () => { runImmediately: true, }); } + + // 运行所有订阅 + const subs = await subscriptionService.list(); + for (const sub of subs) { + await subscriptionService.handleTask(sub); + } }; diff --git a/back/services/sshKey.ts b/back/services/sshKey.ts index 34951644..b707d78e 100644 --- a/back/services/sshKey.ts +++ b/back/services/sshKey.ts @@ -32,7 +32,7 @@ export default class SshKeyService { } private generateSingleSshConfig(alias: string, host: string): string { - return `\nHost ${alias}\n Hostname ${host}\n IdentityFile=${this.sshPath}/${alias}\n StrictHostKeyChecking no`; + return `\nHost ${alias}\n Hostname ${host}\n IdentityFile ${this.sshPath}/${alias}\n StrictHostKeyChecking no`; } private generateSshConfig(configs: string[]) { diff --git a/back/services/subscription.ts b/back/services/subscription.ts index cce105ec..9432c9f3 100644 --- a/back/services/subscription.ts +++ b/back/services/subscription.ts @@ -124,7 +124,7 @@ export default class SubscriptionService { return { url, host }; } - private handleTask(doc: Subscription, needCreate = true, needAddKey = true) { + public handleTask(doc: Subscription, needCreate = true, needAddKey = true) { const { url, host } = this.formatUrl(doc); if (doc.type === 'private-repo' && doc.pull_type === 'ssh-key') { if (needAddKey) { diff --git a/src/pages/crontab/modal.tsx b/src/pages/crontab/modal.tsx index dc65a1ee..0254852e 100644 --- a/src/pages/crontab/modal.tsx +++ b/src/pages/crontab/modal.tsx @@ -75,6 +75,7 @@ const CronModal = ({ value.trim()} rules={[{ required: true, whitespace: true }]} > value.trim()} rules={[ { required: true }, { diff --git a/src/pages/env/modal.tsx b/src/pages/env/modal.tsx index 3862c41d..c8a8663e 100644 --- a/src/pages/env/modal.tsx +++ b/src/pages/env/modal.tsx @@ -79,6 +79,7 @@ const EnvModal = ({ value.trim()} rules={[ { required: true, message: '请输入环境变量名称', whitespace: true }, { @@ -105,6 +106,7 @@ const EnvModal = ({ value.trim()} rules={[ { required: true, message: '请输入环境变量值', whitespace: true }, ]} diff --git a/src/pages/subscription/modal.tsx b/src/pages/subscription/modal.tsx index f5cab843..3e46a4fc 100644 --- a/src/pages/subscription/modal.tsx +++ b/src/pages/subscription/modal.tsx @@ -225,12 +225,13 @@ const SubscriptionModal = ({ 公开仓库 私有仓库 - 单个文件 + 单文件 value.trim()} rules={[ { required: true }, { pattern: type === 'file' ? fileUrlRegx : repoUrlRegx }, @@ -245,7 +246,11 @@ const SubscriptionModal = ({ /> {type !== 'file' && ( - + value.trim()} + > value.trim()} tooltip="多个关键词竖线分割,支持正则表达式" > value.trim()} tooltip="多个关键词竖线分割,支持正则表达式" > value.trim()} tooltip="多个关键词竖线分割,支持正则表达式" >