添加系统错误页面

This commit is contained in:
whyour
2022-02-26 00:12:12 +08:00
parent 7dd87220ab
commit eb4976ed6b
8 changed files with 85 additions and 5 deletions
+11
View File
@@ -0,0 +1,11 @@
.error-wrapper {
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
.react-terminal-wrapper {
max-width: 90%;
height: calc(100vh - 80px);
}
}
+51
View File
@@ -0,0 +1,51 @@
import React, { useState, useEffect } from 'react';
import config from '@/utils/config';
import { request } from '@/utils/http';
import Terminal, { ColorMode, LineType } from 'react-terminal-ui';
import { PageLoading } from '@ant-design/pro-layout';
import { history } from 'umi';
import './index.less';
const Error = ({ user }: any) => {
const [loading, setLoading] = useState(false);
const [data, setData] = useState('暂无日志');
const getLog = () => {
setLoading(true);
request
.get(`${config.apiPrefix}public/panel/log`)
.then((data: any) => {
setData(data.data);
})
.finally(() => setLoading(false));
};
useEffect(() => {
if (user) {
history.push('/');
}
}, [user]);
useEffect(() => {
getLog();
}, []);
return (
<div className="error-wrapper">
{loading ? (
<PageLoading />
) : (
<Terminal
name="服务错误"
colorMode={ColorMode.Light}
lineData={[
{ type: LineType.Input, value: 'pm2 logs panel' },
{ type: LineType.Output, value: data },
]}
/>
)}
</div>
);
};
export default Error;