From 3ccb635956d14e4953b72bf611edfebdb5a557eb Mon Sep 17 00:00:00 2001 From: whyour Date: Wed, 16 Nov 2022 22:34:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A7=BB=E5=8A=A8=E7=AB=AF?= =?UTF-8?q?=E6=9C=80=E5=90=8E=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4=E5=B1=95?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/api/system.ts | 7 +++++-- src/layouts/index.tsx | 2 +- src/pages/setting/about.tsx | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/back/api/system.ts b/back/api/system.ts index f3dc6670..42925b8b 100644 --- a/back/api/system.ts +++ b/back/api/system.ts @@ -8,6 +8,7 @@ import { celebrate, Joi } from 'celebrate'; import UserService from '../services/user'; import { EnvModel } from '../data/env'; import { promiseExec } from '../config/util'; +import dayjs from 'dayjs'; const route = Router(); @@ -25,7 +26,9 @@ export default (app: Router) => { const currentVersionFile = fs.readFileSync(config.versionFile, 'utf8'); const version = currentVersionFile.match(versionRegx)![1]; const lastCommitTime = ( - await promiseExec(`cd ${config.rootPath} && git show -s --format=%ai | head -1`) + await promiseExec( + `cd ${config.rootPath} && git show -s --format=%ai | head -1`, + ) ).replace('\n', ''); const lastCommitId = ( await promiseExec(`cd ${config.rootPath} && git rev-parse --short HEAD`) @@ -50,7 +53,7 @@ export default (app: Router) => { data: { isInitialized, version, - lastCommitTime, + lastCommitTime: dayjs(lastCommitTime).unix(), lastCommitId, branch, }, diff --git a/src/layouts/index.tsx b/src/layouts/index.tsx index 437e1b86..da784eee 100644 --- a/src/layouts/index.tsx +++ b/src/layouts/index.tsx @@ -50,7 +50,7 @@ interface TSystemInfo { branch: 'develop' | 'master'; isInitialized: boolean; lastCommitId: string; - lastCommitTime: string; + lastCommitTime: number; version: string; } diff --git a/src/pages/setting/about.tsx b/src/pages/setting/about.tsx index 23db5b47..94525585 100644 --- a/src/pages/setting/about.tsx +++ b/src/pages/setting/about.tsx @@ -31,7 +31,9 @@ const About = ({ systemInfo }: { systemInfo: SharedContext['systemInfo'] }) => { {TVersion[systemInfo.branch]} v{systemInfo.version} - {dayjs(systemInfo.lastCommitTime).format('YYYY-MM-DD HH:mm:ss')} + {dayjs(systemInfo.lastCommitTime * 1000).format( + 'YYYY-MM-DD HH:mm:ss', + )} {systemInfo.lastCommitId}