mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 06:46:09 +08:00
关于增加版本信息展示
This commit is contained in:
parent
90af5801ee
commit
23bda39812
|
@ -7,6 +7,8 @@ import SystemService from '../services/system';
|
||||||
import { celebrate, Joi } from 'celebrate';
|
import { celebrate, Joi } from 'celebrate';
|
||||||
import UserService from '../services/user';
|
import UserService from '../services/user';
|
||||||
import { EnvModel } from '../data/env';
|
import { EnvModel } from '../data/env';
|
||||||
|
import { promiseExec } from '../config/util';
|
||||||
|
|
||||||
const route = Router();
|
const route = Router();
|
||||||
|
|
||||||
export default (app: Router) => {
|
export default (app: Router) => {
|
||||||
|
@ -22,6 +24,15 @@ export default (app: Router) => {
|
||||||
|
|
||||||
const currentVersionFile = fs.readFileSync(config.versionFile, 'utf8');
|
const currentVersionFile = fs.readFileSync(config.versionFile, 'utf8');
|
||||||
const version = currentVersionFile.match(versionRegx)![1];
|
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;
|
let isInitialized = true;
|
||||||
if (
|
if (
|
||||||
|
@ -37,6 +48,9 @@ export default (app: Router) => {
|
||||||
data: {
|
data: {
|
||||||
isInitialized,
|
isInitialized,
|
||||||
version,
|
version,
|
||||||
|
lastCommitTime,
|
||||||
|
lastCommitId,
|
||||||
|
branch,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -15,7 +15,18 @@ import './index.less';
|
||||||
import vhCheck from 'vh-check';
|
import vhCheck from 'vh-check';
|
||||||
import { version, changeLogLink, changeLog } from '../version';
|
import { version, changeLogLink, changeLog } from '../version';
|
||||||
import { useCtx, useTheme } from '@/utils/hooks';
|
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
|
// @ts-ignore
|
||||||
import SockJS from 'sockjs-client';
|
import SockJS from 'sockjs-client';
|
||||||
import * as Sentry from '@sentry/react';
|
import * as Sentry from '@sentry/react';
|
||||||
|
@ -32,6 +43,15 @@ export interface SharedContext {
|
||||||
reloadUser: (needLoading?: boolean) => void;
|
reloadUser: (needLoading?: boolean) => void;
|
||||||
reloadTheme: () => void;
|
reloadTheme: () => void;
|
||||||
socketMessage: any;
|
socketMessage: any;
|
||||||
|
systemInfo: TSystemInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TSystemInfo {
|
||||||
|
branch: 'develop' | 'master';
|
||||||
|
isInitialized: boolean;
|
||||||
|
lastCommitId: string;
|
||||||
|
lastCommitTime: string;
|
||||||
|
version: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
|
@ -40,7 +60,7 @@ export default function () {
|
||||||
const { theme, reloadTheme } = useTheme();
|
const { theme, reloadTheme } = useTheme();
|
||||||
const [user, setUser] = useState<any>({});
|
const [user, setUser] = useState<any>({});
|
||||||
const [loading, setLoading] = useState<boolean>(true);
|
const [loading, setLoading] = useState<boolean>(true);
|
||||||
const [systemInfo, setSystemInfo] = useState<{ isInitialized: boolean }>();
|
const [systemInfo, setSystemInfo] = useState<TSystemInfo>();
|
||||||
const ws = useRef<any>(null);
|
const ws = useRef<any>(null);
|
||||||
const [socketMessage, setSocketMessage] = useState<any>();
|
const [socketMessage, setSocketMessage] = useState<any>();
|
||||||
const [collapsed, setCollapsed] = useState(false);
|
const [collapsed, setCollapsed] = useState(false);
|
||||||
|
@ -256,17 +276,23 @@ export default function () {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<span
|
<Tooltip
|
||||||
style={{
|
title={systemInfo?.branch === 'develop' ? '开发版' : '正式版'}
|
||||||
fontSize: isFirefox ? 9 : 12,
|
|
||||||
color: '#666',
|
|
||||||
marginLeft: 2,
|
|
||||||
zoom: isSafari ? 0.66 : 0.8,
|
|
||||||
letterSpacing: isQQBrowser ? -2 : 0,
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
v{version}
|
<Badge size="small" dot={systemInfo?.branch === 'develop'}>
|
||||||
</span>
|
<span
|
||||||
|
style={{
|
||||||
|
fontSize: isFirefox ? 9 : 12,
|
||||||
|
color: '#666',
|
||||||
|
marginLeft: 2,
|
||||||
|
zoom: isSafari ? 0.66 : 0.8,
|
||||||
|
letterSpacing: isQQBrowser ? -2 : 0,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
v{version}
|
||||||
|
</span>
|
||||||
|
</Badge>
|
||||||
|
</Tooltip>
|
||||||
</a>
|
</a>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
|
@ -342,6 +368,7 @@ export default function () {
|
||||||
reloadUser,
|
reloadUser,
|
||||||
reloadTheme,
|
reloadTheme,
|
||||||
socketMessage,
|
socketMessage,
|
||||||
|
systemInfo,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</ProLayout>
|
</ProLayout>
|
||||||
|
|
|
@ -1,10 +1,17 @@
|
||||||
import React, { useEffect, useState } from 'react';
|
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 styles from './index.less';
|
||||||
|
import { SharedContext } from '@/layouts';
|
||||||
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
const { Link } = Typography;
|
const { Link } = Typography;
|
||||||
|
|
||||||
const About = () => {
|
enum TVersion {
|
||||||
|
'develop' = '开发版',
|
||||||
|
'master' = '正式版',
|
||||||
|
}
|
||||||
|
|
||||||
|
const About = ({ systemInfo }: { systemInfo: SharedContext['systemInfo'] }) => {
|
||||||
return (
|
return (
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
<img
|
<img
|
||||||
|
@ -19,6 +26,17 @@ const About = () => {
|
||||||
task management panel that supports typescript, javaScript, python3,
|
task management panel that supports typescript, javaScript, python3,
|
||||||
and shell.)
|
and shell.)
|
||||||
</span>
|
</span>
|
||||||
|
<Descriptions>
|
||||||
|
<Descriptions.Item label="版本" span={3}>
|
||||||
|
{TVersion[systemInfo.branch]} v{systemInfo.version}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="更新时间" span={3}>
|
||||||
|
{dayjs(systemInfo.lastCommitTime).format('YYYY-MM-DD HH:mm:ss')}
|
||||||
|
</Descriptions.Item>
|
||||||
|
<Descriptions.Item label="更新ID" span={3}>
|
||||||
|
{systemInfo.lastCommitId}
|
||||||
|
</Descriptions.Item>
|
||||||
|
</Descriptions>
|
||||||
<div>
|
<div>
|
||||||
<Link
|
<Link
|
||||||
href="https://github.com/whyour/qinglong"
|
href="https://github.com/whyour/qinglong"
|
||||||
|
|
|
@ -18,5 +18,12 @@
|
||||||
.desc {
|
.desc {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:global {
|
||||||
|
.ant-descriptions-row > th,
|
||||||
|
.ant-descriptions-row > td {
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,8 +40,15 @@ const optionsWithDisabled = [
|
||||||
];
|
];
|
||||||
|
|
||||||
const Setting = () => {
|
const Setting = () => {
|
||||||
const { headerStyle, isPhone, user, reloadUser, reloadTheme, socketMessage } =
|
const {
|
||||||
useOutletContext<SharedContext>();
|
headerStyle,
|
||||||
|
isPhone,
|
||||||
|
user,
|
||||||
|
reloadUser,
|
||||||
|
reloadTheme,
|
||||||
|
socketMessage,
|
||||||
|
systemInfo,
|
||||||
|
} = useOutletContext<SharedContext>();
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
title: '名称',
|
title: '名称',
|
||||||
|
@ -411,7 +418,7 @@ const Setting = () => {
|
||||||
{
|
{
|
||||||
key: 'about',
|
key: 'about',
|
||||||
label: '关于',
|
label: '关于',
|
||||||
children: <About />,
|
children: <About systemInfo={systemInfo} />,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
></Tabs>
|
></Tabs>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user