From 23bda3981266cf18ec551f147f418d9d531bb839 Mon Sep 17 00:00:00 2001 From: whyour Date: Sat, 5 Nov 2022 11:01:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E4=BA=8E=E5=A2=9E=E5=8A=A0=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E4=BF=A1=E6=81=AF=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/api/system.ts | 14 ++++++++++ src/layouts/index.tsx | 51 +++++++++++++++++++++++++++--------- src/pages/setting/about.tsx | 22 ++++++++++++++-- src/pages/setting/index.less | 7 +++++ src/pages/setting/index.tsx | 13 ++++++--- 5 files changed, 90 insertions(+), 17 deletions(-) diff --git a/back/api/system.ts b/back/api/system.ts index cd6f722f..e7ce2e0d 100644 --- a/back/api/system.ts +++ b/back/api/system.ts @@ -7,6 +7,8 @@ import SystemService from '../services/system'; import { celebrate, Joi } from 'celebrate'; import UserService from '../services/user'; import { EnvModel } from '../data/env'; +import { promiseExec } from '../config/util'; + const route = Router(); export default (app: Router) => { @@ -22,6 +24,15 @@ export default (app: Router) => { const currentVersionFile = fs.readFileSync(config.versionFile, 'utf8'); const version = currentVersionFile.match(versionRegx)![1]; + const lastCommitTime = ( + await promiseExec('git show -s --format=%ai') + ).replace('\n', ''); + const lastCommitId = ( + await promiseExec('git rev-parse --short HEAD') + ).replace('\n', ''); + const branch = ( + await promiseExec('git symbolic-ref --short HEAD') + ).replace('\n', ''); let isInitialized = true; if ( @@ -37,6 +48,9 @@ export default (app: Router) => { data: { isInitialized, version, + lastCommitTime, + lastCommitId, + branch, }, }); } catch (e) { diff --git a/src/layouts/index.tsx b/src/layouts/index.tsx index f843e8b1..437e1b86 100644 --- a/src/layouts/index.tsx +++ b/src/layouts/index.tsx @@ -15,7 +15,18 @@ import './index.less'; import vhCheck from 'vh-check'; import { version, changeLogLink, changeLog } from '../version'; import { useCtx, useTheme } from '@/utils/hooks'; -import { message, Badge, Modal, Avatar, Dropdown, Menu, Image } from 'antd'; +import { + message, + Badge, + Modal, + Avatar, + Dropdown, + Menu, + Image, + Popover, + Descriptions, + Tooltip, +} from 'antd'; // @ts-ignore import SockJS from 'sockjs-client'; import * as Sentry from '@sentry/react'; @@ -32,6 +43,15 @@ export interface SharedContext { reloadUser: (needLoading?: boolean) => void; reloadTheme: () => void; socketMessage: any; + systemInfo: TSystemInfo; +} + +interface TSystemInfo { + branch: 'develop' | 'master'; + isInitialized: boolean; + lastCommitId: string; + lastCommitTime: string; + version: string; } export default function () { @@ -40,7 +60,7 @@ export default function () { const { theme, reloadTheme } = useTheme(); const [user, setUser] = useState({}); const [loading, setLoading] = useState(true); - const [systemInfo, setSystemInfo] = useState<{ isInitialized: boolean }>(); + const [systemInfo, setSystemInfo] = useState(); const ws = useRef(null); const [socketMessage, setSocketMessage] = useState(); const [collapsed, setCollapsed] = useState(false); @@ -256,17 +276,23 @@ export default function () { e.stopPropagation(); }} > - - v{version} - + + + v{version} + + + } @@ -342,6 +368,7 @@ export default function () { reloadUser, reloadTheme, socketMessage, + systemInfo, }} /> diff --git a/src/pages/setting/about.tsx b/src/pages/setting/about.tsx index f077ecd8..23db5b47 100644 --- a/src/pages/setting/about.tsx +++ b/src/pages/setting/about.tsx @@ -1,10 +1,17 @@ import React, { useEffect, useState } from 'react'; -import { Typography, Input, Form, Button, message } from 'antd'; +import { Typography, Input, Form, Button, message, Descriptions } from 'antd'; import styles from './index.less'; +import { SharedContext } from '@/layouts'; +import dayjs from 'dayjs'; const { Link } = Typography; -const About = () => { +enum TVersion { + 'develop' = '开发版', + 'master' = '正式版', +} + +const About = ({ systemInfo }: { systemInfo: SharedContext['systemInfo'] }) => { return (
{ task management panel that supports typescript, javaScript, python3, and shell.) + + + {TVersion[systemInfo.branch]} v{systemInfo.version} + + + {dayjs(systemInfo.lastCommitTime).format('YYYY-MM-DD HH:mm:ss')} + + + {systemInfo.lastCommitId} + +
th, + .ant-descriptions-row > td { + padding-bottom: 10px; + } + } } } diff --git a/src/pages/setting/index.tsx b/src/pages/setting/index.tsx index 56539cb9..8fd13aec 100644 --- a/src/pages/setting/index.tsx +++ b/src/pages/setting/index.tsx @@ -40,8 +40,15 @@ const optionsWithDisabled = [ ]; const Setting = () => { - const { headerStyle, isPhone, user, reloadUser, reloadTheme, socketMessage } = - useOutletContext(); + const { + headerStyle, + isPhone, + user, + reloadUser, + reloadTheme, + socketMessage, + systemInfo, + } = useOutletContext(); const columns = [ { title: '名称', @@ -411,7 +418,7 @@ const Setting = () => { { key: 'about', label: '关于', - children: , + children: , }, ]} >