From a3006af7b8f1690a54ea402a0b71890bcc9a89c0 Mon Sep 17 00:00:00 2001
From: hanhh <18330117883@163.com>
Date: Wed, 6 Oct 2021 16:22:53 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E7=89=88=E6=9C=AC?=
=?UTF-8?q?=E6=8F=90=E9=86=92?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/layouts/index.tsx | 95 +++++++++++++++++++++++++++++--------------
1 file changed, 64 insertions(+), 31 deletions(-)
diff --git a/src/layouts/index.tsx b/src/layouts/index.tsx
index e06f8d03..8c5e8e2e 100644
--- a/src/layouts/index.tsx
+++ b/src/layouts/index.tsx
@@ -15,7 +15,7 @@ import './index.less';
import vhCheck from 'vh-check';
import { version, changeLog } from '../version';
import { useCtx, useTheme } from '@/utils/hooks';
-import { message } from 'antd';
+import { message, Badge, Typography } from 'antd';
export default function (props: any) {
const ctx = useCtx();
@@ -32,35 +32,44 @@ export default function (props: any) {
};
const getSystemInfo = () => {
- request.get(`${config.apiPrefix}system`).then(({ code, data }) => {
- if (code === 200) {
- setSystemInfo(data);
- if (!data.isInitialized) {
- history.push('/initialization');
- setLoading(false);
+ request
+ .get(`${config.apiPrefix}system`)
+ .then(({ code, data }) => {
+ if (code === 200) {
+ setSystemInfo(data);
+ if (!data.isInitialized) {
+ history.push('/initialization');
+ setLoading(false);
+ } else {
+ getUser();
+ }
} else {
- getUser();
+ message.error(data);
}
- } else {
- message.error(data);
- }
- });
+ })
+ .catch((error) => {
+ console.log(error);
+ });
};
const getUser = (needLoading = true) => {
needLoading && setLoading(true);
- request.get(`${config.apiPrefix}user`).then(({ code, data }) => {
- if (code === 200 && data.username) {
- setUser(data);
- localStorage.setItem('isLogin', 'true');
- if (props.location.pathname === '/') {
- history.push('/crontab');
+ request
+ .get(`${config.apiPrefix}user`)
+ .then(({ code, data }) => {
+ if (code === 200 && data.username) {
+ setUser(data);
+ if (props.location.pathname === '/') {
+ history.push('/crontab');
+ }
+ } else {
+ message.error(data);
}
- } else {
- message.error(data);
- }
- needLoading && setLoading(false);
- });
+ needLoading && setLoading(false);
+ })
+ .catch((error) => {
+ console.log(error);
+ });
};
const reloadUser = () => {
@@ -135,19 +144,43 @@ export default function (props: any) {
title={
<>
控制面板
-
- {
+ alert('yes');
+ }}
+ >
+
- {version}
-
-
+ {
+ e.stopPropagation();
+ }}
+ >
+
+ {version}
+
+
+
+
>
}
menuItemRender={(menuItemProps: any, defaultDom: any) => {