feat: add version display

This commit is contained in:
moonrailgun 2024-01-07 23:22:39 +08:00
parent d03f60f6a1
commit ac7f4011cd
5 changed files with 25 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import { Button, Dropdown } from 'antd';
import { useUserStore } from '../store/user'; import { useUserStore } from '../store/user';
import { useLogout } from '../api/model/user'; import { useLogout } from '../api/model/user';
import { ColorSchemeSwitcher } from '../components/ColorSchemeSwitcher'; import { ColorSchemeSwitcher } from '../components/ColorSchemeSwitcher';
import { version } from '../../shared';
export const Layout: React.FC = React.memo(() => { export const Layout: React.FC = React.memo(() => {
const [params] = useSearchParams(); const [params] = useSearchParams();
@ -66,6 +67,14 @@ export const Layout: React.FC = React.memo(() => {
logout(); logout();
}, },
}, },
{
type: 'divider',
},
{
key: 'version',
label: `v${version}`,
disabled: true,
},
], ],
}} }}
> >

View File

@ -26,6 +26,7 @@ import { serverStatusRouter } from './router/serverStatus';
import { initCronjob } from './cronjob'; import { initCronjob } from './cronjob';
import { logger } from './utils/logger'; import { logger } from './utils/logger';
import { monitorRouter } from './router/monitor'; import { monitorRouter } from './router/monitor';
import { healthRouter } from './router/health';
const port = settings.port; const port = settings.port;
@ -56,6 +57,7 @@ app.use(
}) })
); );
app.use('/health', healthRouter);
app.use('/api/website', websiteRouter); app.use('/api/website', websiteRouter);
app.use('/api/workspace', workspaceRouter); app.use('/api/workspace', workspaceRouter);
app.use('/monitor', monitorRouter); app.use('/monitor', monitorRouter);

View File

@ -0,0 +1,10 @@
import { Router } from 'express';
import { version } from '../../shared';
export const healthRouter = Router();
healthRouter.get('/', async (req, res) => {
res.json({
version,
});
});

3
src/shared/config.ts Normal file
View File

@ -0,0 +1,3 @@
import packageJson from '../../package.json';
export const version = packageJson.version;

View File

@ -1,3 +1,4 @@
export * from './config';
export * from './date'; export * from './date';
export * from './server'; export * from './server';
export * from './regex'; export * from './regex';