From 31ff0476a680c7123ddf68d105ce7bb8202d9396 Mon Sep 17 00:00:00 2001 From: whyour Date: Sat, 28 May 2022 17:36:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=BB=E5=8A=A1=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E6=97=A5=E5=BF=97=E8=AE=BF=E9=97=AE=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E6=96=B0=E5=BB=BA=E8=AE=A2=E9=98=85=E7=B2=98=E8=B4=B4?= =?UTF-8?q?repo=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/api/log.ts | 2 +- back/services/subscription.ts | 10 ++++++---- src/pages/crontab/detail.tsx | 8 ++++++-- src/pages/subscription/modal.tsx | 5 ++++- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/back/api/log.ts b/back/api/log.ts index 3839dfe0..918d4118 100644 --- a/back/api/log.ts +++ b/back/api/log.ts @@ -31,7 +31,7 @@ export default (app: Router) => { try { const filePath = join( config.logPath, - req.query.path as string, + (req.query.path || '') as string, req.params.file, ); const content = getFileContentByName(filePath); diff --git a/back/services/subscription.ts b/back/services/subscription.ts index eb6d54e0..8a7921eb 100644 --- a/back/services/subscription.ts +++ b/back/services/subscription.ts @@ -181,8 +181,9 @@ export default class SubscriptionService { if (doc.sub_before) { beforeStr = execSync(doc.sub_before).toString(); } - } catch (error) { - beforeStr = JSON.stringify(error); + } catch (error: any) { + beforeStr = + (error.stderr && error.stderr.toString()) || JSON.stringify(error); } if (beforeStr) { beforeStr += '\n'; @@ -225,8 +226,9 @@ export default class SubscriptionService { if (sub.sub_after) { afterStr = execSync(sub.sub_after).toString(); } - } catch (error) { - afterStr = JSON.stringify(error); + } catch (error: any) { + afterStr = + (error.stderr && error.stderr.toString()) || JSON.stringify(error); } if (afterStr) { afterStr = `\n\n${afterStr}`; diff --git a/src/pages/crontab/detail.tsx b/src/pages/crontab/detail.tsx index d5c571c3..5dabea76 100644 --- a/src/pages/crontab/detail.tsx +++ b/src/pages/crontab/detail.tsx @@ -115,9 +115,13 @@ const CronDetailModal = ({ const onClickItem = (item: LogItem) => { localStorage.setItem('logCron', currentCron.id); - setLogUrl(`${config.apiPrefix}logs/${item.directory}/${item.filename}`); + setLogUrl( + `${config.apiPrefix}logs/${item.filename}?path=${item.directory || ''}`, + ); request - .get(`${config.apiPrefix}logs/${item.directory}/${item.filename}`) + .get( + `${config.apiPrefix}logs/${item.filename}?path=${item.directory || ''}`, + ) .then((data) => { setLog(data.data); setIsLogModalVisible(true); diff --git a/src/pages/subscription/modal.tsx b/src/pages/subscription/modal.tsx index 9881f715..7ac0c211 100644 --- a/src/pages/subscription/modal.tsx +++ b/src/pages/subscription/modal.tsx @@ -195,7 +195,9 @@ const SubscriptionModal = ({ dependences, branch, extensions, - ] = text.split(' ').map((x) => x.trim()); + ] = text + .split(' ') + .map((x) => x.trim().replace(/\"/g, '').replace(/\'/, '')); form.setFieldsValue({ type: type === 'raw' @@ -210,6 +212,7 @@ const SubscriptionModal = ({ branch, extensions, }); + form.validateFields(['url']); } }, []);