系统设置增加重启

This commit is contained in:
whyour 2024-01-22 23:36:11 +08:00
parent 06f861baaf
commit 48d1fba699
5 changed files with 63 additions and 36 deletions

View File

@ -74,6 +74,9 @@ export default (app: Router) => {
async (req: Request, res: Response, next: NextFunction) => { async (req: Request, res: Response, next: NextFunction) => {
const logger: Logger = Container.get('logger'); const logger: Logger = Container.get('logger');
try { try {
if (process.env.DeployEnv === 'demo') {
return res.send({ code: 450, message: '未知错误' });
}
const userService = Container.get(UserService); const userService = Container.get(UserService);
await userService.updateUsernameAndPassword(req.body); await userService.updateUsernameAndPassword(req.body);
res.send({ code: 200, message: '更新成功' }); res.send({ code: 200, message: '更新成功' });

View File

@ -237,6 +237,7 @@
"系统将在": "The system will restart in", "系统将在": "The system will restart in",
"秒后自动刷新": "seconds and automatically refresh", "秒后自动刷新": "seconds and automatically refresh",
"检查更新": "Check for Updates", "检查更新": "Check for Updates",
"重新启动": "Reboot",
"确认删除应用": "Confirm to delete the application", "确认删除应用": "Confirm to delete the application",
"确认重置": "Confirm to reset", "确认重置": "Confirm to reset",
"确认重置应用": "Confirm to reset the application", "确认重置应用": "Confirm to reset the application",

View File

@ -237,6 +237,7 @@
"系统将在": "系统将在", "系统将在": "系统将在",
"秒后自动刷新": "秒后自动刷新", "秒后自动刷新": "秒后自动刷新",
"检查更新": "检查更新", "检查更新": "检查更新",
"重新启动": "重新启动",
"确认删除应用": "确认删除应用", "确认删除应用": "确认删除应用",
"确认重置": "确认重置", "确认重置": "确认重置",
"确认重置应用": "确认重置应用", "确认重置应用": "确认重置应用",

View File

@ -77,7 +77,11 @@ const CheckUpdate = ({ systemInfo }: any) => {
</div> </div>
</> </>
), ),
content: <pre><Ansi>{lastLog}</Ansi></pre>, content: (
<pre>
<Ansi>{lastLog}</Ansi>
</pre>
),
okText: intl.get('下载更新'), okText: intl.get('下载更新'),
cancelText: intl.get('以后再说'), cancelText: intl.get('以后再说'),
onOk() { onOk() {
@ -102,19 +106,15 @@ const CheckUpdate = ({ systemInfo }: any) => {
okButtonProps: { disabled: true }, okButtonProps: { disabled: true },
title: intl.get('下载更新中...'), title: intl.get('下载更新中...'),
centered: true, centered: true,
content: <pre><Ansi>{value}</Ansi></pre>, content: (
<pre>
<Ansi>{value}</Ansi>
</pre>
),
}); });
}; };
const showReloadModal = () => { const reloadSystem = () => {
Modal.confirm({
width: 600,
maskClosable: false,
title: intl.get('确认重启'),
centered: true,
content: intl.get('系统安装包下载成功,确认重启'),
okText: intl.get('重启'),
onOk() {
request request
.put(`${config.apiPrefix}system/reload`, { type: 'system' }) .put(`${config.apiPrefix}system/reload`, { type: 'system' })
.then((_data: any) => { .then((_data: any) => {
@ -139,6 +139,18 @@ const CheckUpdate = ({ systemInfo }: any) => {
.catch((error: any) => { .catch((error: any) => {
console.log(error); console.log(error);
}); });
};
const showReloadModal = () => {
Modal.confirm({
width: 600,
maskClosable: false,
title: intl.get('确认重启'),
centered: true,
content: intl.get('系统安装包下载成功,确认重启'),
okText: intl.get('重启'),
onOk() {
reloadSystem();
}, },
onCancel() { onCancel() {
modalRef.current.update({ modalRef.current.update({
@ -206,6 +218,9 @@ const CheckUpdate = ({ systemInfo }: any) => {
<Button type="primary" onClick={checkUpgrade}> <Button type="primary" onClick={checkUpgrade}>
{intl.get('检查更新')} {intl.get('检查更新')}
</Button> </Button>
<Button type="primary" onClick={reloadSystem} style={{ marginLeft: 8 }}>
{intl.get('重新启动')}
</Button>
</> </>
); );
}; };

View File

@ -75,11 +75,19 @@ const Setting = () => {
title: intl.get('权限'), title: intl.get('权限'),
dataIndex: 'scopes', dataIndex: 'scopes',
key: 'scopes', key: 'scopes',
width: '40%', width: 500,
render: (text: string, record: any) => { render: (text: string, record: any) => {
return record.scopes.map((scope: any) => { return (
return <Tag key={scope}>{(config.scopesMap as any)[scope]}</Tag>; <div style={{ display: 'flex', gap: 4, flexWrap: 'wrap' }}>
}); {record.scopes.map((scope: any) => {
return (
<Tag style={{ marginRight: 0 }} key={scope}>
{(config.scopesMap as any)[scope]}
</Tag>
);
})}
</div>
);
}, },
}, },
{ {
@ -348,7 +356,9 @@ const Setting = () => {
{ {
key: 'syslog', key: 'syslog',
label: intl.get('系统日志'), label: intl.get('系统日志'),
children: <SystemLog data={systemLogData} height={height} theme={theme}/>, children: (
<SystemLog data={systemLogData} height={height} theme={theme} />
),
}, },
{ {
key: 'login', key: 'login',
@ -358,16 +368,13 @@ const Setting = () => {
{ {
key: 'dependence', key: 'dependence',
label: intl.get('依赖设置'), label: intl.get('依赖设置'),
children: <Dependence /> children: <Dependence />,
}, },
{ {
key: 'other', key: 'other',
label: intl.get('其他设置'), label: intl.get('其他设置'),
children: ( children: (
<Other <Other reloadTheme={reloadTheme} systemInfo={systemInfo} />
reloadTheme={reloadTheme}
systemInfo={systemInfo}
/>
), ),
}, },
{ {