系统设置增加重启

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) => {
const logger: Logger = Container.get('logger');
try {
if (process.env.DeployEnv === 'demo') {
return res.send({ code: 450, message: '未知错误' });
}
const userService = Container.get(UserService);
await userService.updateUsernameAndPassword(req.body);
res.send({ code: 200, message: '更新成功' });

View File

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

View File

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

View File

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

View File

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