mirror of
https://github.com/whyour/qinglong.git
synced 2026-07-17 17:46:01 +08:00
修复错误信息展示
This commit is contained in:
+7
-3
@@ -3,13 +3,17 @@ import intl from 'react-intl-universal';
|
||||
|
||||
export function rootContainer(container: any) {
|
||||
const locales = {
|
||||
'en-US': require('./locales/en-US.json'),
|
||||
'zh-CN': require('./locales/zh-CN.json'),
|
||||
'en': require('./locales/en-US.json'),
|
||||
'zh': require('./locales/zh-CN.json'),
|
||||
};
|
||||
let currentLocale = intl.determineLocale({
|
||||
urlLocaleKey: 'lang',
|
||||
cookieLocaleKey: 'lang',
|
||||
});
|
||||
}).slice(0, 2);
|
||||
|
||||
if (!currentLocale || !Object.keys(locales).includes(currentLocale)) {
|
||||
currentLocale = 'zh';
|
||||
}
|
||||
|
||||
intl.init({ currentLocale, locales });
|
||||
return container;
|
||||
|
||||
@@ -47,7 +47,7 @@ const CronLogModal = ({
|
||||
const log = data as string;
|
||||
setValue(log || intl.get('暂无日志'));
|
||||
const hasNext = Boolean(
|
||||
log && !logEnded(log) && !log.includes(intl.get('任务未运行')),
|
||||
log && !logEnded(log) && !log.includes('任务未运行'),
|
||||
);
|
||||
setExecuting(hasNext);
|
||||
autoScroll();
|
||||
|
||||
@@ -9,17 +9,22 @@ import { SharedContext } from '@/layouts';
|
||||
import { Alert, Typography } from 'antd';
|
||||
|
||||
const Error = () => {
|
||||
const { user, theme, reloadUser } = useOutletContext<SharedContext>();
|
||||
const { user } = useOutletContext<SharedContext>();
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [data, setData] = useState(intl.get('暂无日志'));
|
||||
const retryTimes = useRef(1);
|
||||
|
||||
const getLog = (needLoading: boolean = true) => {
|
||||
const getHealthStatus = (needLoading: boolean = true) => {
|
||||
needLoading && setLoading(true);
|
||||
request
|
||||
.get(`${config.apiPrefix}public/health`)
|
||||
.then(({ error, data }) => {
|
||||
if (data?.status === 1) {
|
||||
if (retryTimes.current > 1) {
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (retryTimes.current > 3) {
|
||||
@@ -28,7 +33,7 @@ const Error = () => {
|
||||
}
|
||||
retryTimes.current += 1;
|
||||
setTimeout(() => {
|
||||
getLog(false);
|
||||
getHealthStatus(false);
|
||||
}, 3000);
|
||||
})
|
||||
.finally(() => needLoading && setLoading(false));
|
||||
@@ -41,7 +46,7 @@ const Error = () => {
|
||||
}, [user]);
|
||||
|
||||
useEffect(() => {
|
||||
getLog();
|
||||
getHealthStatus();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user