mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 23:06:06 +08:00
添加系统错误页面
This commit is contained in:
parent
03f4b5c219
commit
01564e96d3
|
@ -100,6 +100,7 @@
|
|||
"react-dnd-html5-backend": "^14.0.0",
|
||||
"react-dom": "17.x",
|
||||
"react-split-pane": "^0.1.92",
|
||||
"react-terminal-ui": "^0.1.14",
|
||||
"sockjs-client": "^1.5.2",
|
||||
"ts-node": "^9.0.0",
|
||||
"typescript": "^4.1.2",
|
||||
|
|
|
@ -25,6 +25,12 @@ export default {
|
|||
hideInMenu: true,
|
||||
component: '@/pages/initialization/index',
|
||||
},
|
||||
{
|
||||
name: '错误',
|
||||
path: '/error',
|
||||
hideInMenu: true,
|
||||
component: '@/pages/error/index',
|
||||
},
|
||||
{
|
||||
path: '/crontab',
|
||||
name: '定时任务',
|
||||
|
|
|
@ -179,7 +179,9 @@ export default function (props: any) {
|
|||
};
|
||||
}, []);
|
||||
|
||||
if (['/login', '/initialization'].includes(props.location.pathname)) {
|
||||
if (
|
||||
['/login', '/initialization', '/error'].includes(props.location.pathname)
|
||||
) {
|
||||
document.title = `${
|
||||
(config.documentTitleMap as any)[props.location.pathname]
|
||||
} - 控制面板`;
|
||||
|
@ -190,7 +192,7 @@ export default function (props: any) {
|
|||
history.push('/crontab');
|
||||
}
|
||||
|
||||
if (systemInfo) {
|
||||
if (systemInfo || props.location.pathname === '/error') {
|
||||
return React.Children.map(props.children, (child) => {
|
||||
return React.cloneElement(child, {
|
||||
...ctx,
|
||||
|
|
11
src/pages/error/index.less
Normal file
11
src/pages/error/index.less
Normal 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
src/pages/error/index.tsx
Normal file
51
src/pages/error/index.tsx
Normal 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;
|
|
@ -119,7 +119,10 @@ export default {
|
|||
tip: 'Bark的信息IP/设备码,例如:https://api.day.app/XXXXXXXX',
|
||||
required: true,
|
||||
},
|
||||
{ label: 'barkIcon', tip: 'BARK推送图标,自定义推送图标 (需iOS15或以上才能显示)' },
|
||||
{
|
||||
label: 'barkIcon',
|
||||
tip: 'BARK推送图标,自定义推送图标 (需iOS15或以上才能显示)',
|
||||
},
|
||||
{ label: 'barkSound', tip: 'BARK推送铃声,铃声列表去APP查看复制填写' },
|
||||
{ label: 'barkGroup', tip: 'BARK推送消息的分组, 默认为qinglong' },
|
||||
],
|
||||
|
@ -208,6 +211,7 @@ export default {
|
|||
'/diff': '对比工具',
|
||||
'/log': '任务日志',
|
||||
'/setting': '系统设置',
|
||||
'/error': '错误日志',
|
||||
},
|
||||
dependenceTypes: ['nodejs', 'python3', 'linux'],
|
||||
};
|
||||
|
|
|
@ -14,8 +14,8 @@ const errorHandler = function (error: any) {
|
|||
? error.data.message || error.data
|
||||
: error.response.statusText;
|
||||
const responseStatus = error.response.status;
|
||||
if (responseStatus === 502) {
|
||||
message.error('服务异常,请手动执行ql check检查服务状态');
|
||||
if ([502, 504].includes(responseStatus)) {
|
||||
history.push('/error');
|
||||
} else if (responseStatus === 401) {
|
||||
if (history.location.pathname !== '/login') {
|
||||
message.error('登录已过期,请重新登录');
|
||||
|
|
|
@ -9207,6 +9207,11 @@ react-style-proptype@^3.2.2:
|
|||
dependencies:
|
||||
prop-types "^15.5.4"
|
||||
|
||||
react-terminal-ui@^0.1.14:
|
||||
version "0.1.14"
|
||||
resolved "https://registry.yarnpkg.com/react-terminal-ui/-/react-terminal-ui-0.1.14.tgz#c024853da862d83f1a5720f92ffb7e91c508a4cf"
|
||||
integrity sha512-VTk4/kjSV1ElyiBP2mWlXwU+UscIb7edolYlZcL+MqZBrx5hbI/O6zaG+7nCMih5Nk4fjbKEysxCcOvf8k5J8A==
|
||||
|
||||
react-tween-state@^0.1.5:
|
||||
version "0.1.5"
|
||||
resolved "https://registry.npmjs.org/react-tween-state/-/react-tween-state-0.1.5.tgz"
|
||||
|
|
Loading…
Reference in New Issue
Block a user