diff --git a/react-ui/config/config.ts b/react-ui/config/config.ts
index 405f85cb..4d7d3db8 100644
--- a/react-ui/config/config.ts
+++ b/react-ui/config/config.ts
@@ -163,4 +163,5 @@ export default defineConfig({
},
javascriptEnabled: true,
},
+ // plugins: ['umi-plugin-keep-alive'],
});
diff --git a/react-ui/src/app.tsx b/react-ui/src/app.tsx
index 10ab35bb..f8a3221b 100644
--- a/react-ui/src/app.tsx
+++ b/react-ui/src/app.tsx
@@ -133,22 +133,7 @@ export const layout: RunTimeLayoutConfig = ({ initialState }) => {
// 增加一个 loading 的状态
childrenRender: (children) => {
// if (initialState?.loading) return ;
- return (
- <>
- {children}
- {/* {
- setInitialState((preInitialState) => ({
- ...preInitialState,
- settings,
- }));
- }}
- /> */}
- >
- );
+ return <>{children}>;
},
...initialState?.settings,
};
diff --git a/react-ui/src/components/HeaderDropdown/index.tsx b/react-ui/src/components/HeaderDropdown/index.tsx
index ae560fd2..36153a73 100644
--- a/react-ui/src/components/HeaderDropdown/index.tsx
+++ b/react-ui/src/components/HeaderDropdown/index.tsx
@@ -17,13 +17,8 @@ const HeaderDropdown: React.FC = ({ overlayClassName: cls,
},
};
});
- return (
- target.parentElement || document.body}
- {...restProps}
- />
- );
+
+ return ;
};
export default HeaderDropdown;
diff --git a/react-ui/src/components/RightContent/AvatarDropdown.tsx b/react-ui/src/components/RightContent/AvatarDropdown.tsx
index c6c52a92..fca317ef 100644
--- a/react-ui/src/components/RightContent/AvatarDropdown.tsx
+++ b/react-ui/src/components/RightContent/AvatarDropdown.tsx
@@ -1,13 +1,12 @@
import { clearSessionToken } from '@/access';
-import { PageEnum } from '@/enums/pagesEnums';
import { setRemoteMenu } from '@/services/session';
import { logout } from '@/services/system/auth';
+import { gotoLoginPage } from '@/utils/ui';
import { LogoutOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons';
import { setAlpha } from '@ant-design/pro-components';
import { useEmotionCss } from '@ant-design/use-emotion-css';
import { history, useModel } from '@umijs/max';
import { Avatar, Spin } from 'antd';
-import { stringify } from 'querystring';
import type { MenuInfo } from 'rc-menu/lib/interface';
import React, { useCallback } from 'react';
import { flushSync } from 'react-dom';
@@ -23,7 +22,7 @@ const Name = () => {
const nameClassName = useEmotionCss(({ token }) => {
return {
- width: '70px',
+ // width: '70px',
height: '48px',
overflow: 'hidden',
lineHeight: '48px',
@@ -64,19 +63,7 @@ const AvatarDropdown: React.FC = ({ menu }) => {
await logout();
clearSessionToken();
setRemoteMenu(null);
- const { search, pathname } = window.location;
- const urlParams = new URL(window.location.href).searchParams;
- /** 此方法会跳转到 redirect 参数所在的位置 */
- const redirect = urlParams.get('redirect');
- // Note: There may be security issues, please note
- if (window.location.pathname !== PageEnum.LOGIN && !redirect) {
- history.replace({
- pathname: PageEnum.LOGIN,
- search: stringify({
- redirect: pathname + search,
- }),
- });
- }
+ gotoLoginPage();
};
const actionClassName = useEmotionCss(({ token }) => {
return {
diff --git a/react-ui/src/components/RightContent/index.tsx b/react-ui/src/components/RightContent/index.tsx
index c2a4a7bf..6fbfa37c 100644
--- a/react-ui/src/components/RightContent/index.tsx
+++ b/react-ui/src/components/RightContent/index.tsx
@@ -1,6 +1,5 @@
-import { QuestionCircleOutlined } from '@ant-design/icons';
import { useEmotionCss } from '@ant-design/use-emotion-css';
-import { SelectLang, useModel } from '@umijs/max';
+import { useModel } from '@umijs/max';
import React from 'react';
import Avatar from './AvatarDropdown';
@@ -17,21 +16,21 @@ const GlobalHeaderRight: React.FC = () => {
};
});
- const actionClassName = useEmotionCss(({ token }) => {
- return {
- display: 'flex',
- float: 'right',
- height: '48px',
- marginLeft: 'auto',
- overflow: 'hidden',
- cursor: 'pointer',
- padding: '0 12px',
- borderRadius: token.borderRadius,
- '&:hover': {
- backgroundColor: token.colorBgTextHover,
- },
- };
- });
+ // const actionClassName = useEmotionCss(({ token }) => {
+ // return {
+ // display: 'flex',
+ // float: 'right',
+ // height: '48px',
+ // marginLeft: 'auto',
+ // overflow: 'hidden',
+ // cursor: 'pointer',
+ // padding: '0 12px',
+ // borderRadius: token.borderRadius,
+ // '&:hover': {
+ // backgroundColor: token.colorBgTextHover,
+ // },
+ // };
+ // });
const { initialState } = useModel('@@initialState');
@@ -41,15 +40,15 @@ const GlobalHeaderRight: React.FC = () => {
return (
-
{
window.open('https://pro.ant.design/docs/getting-started');
}}
>
-
-
+ */}
+
{/*
*/}
);
diff --git a/react-ui/src/pages/Experiment/experimentText/addExperimentModal.tsx b/react-ui/src/pages/Experiment/experimentText/addExperimentModal.tsx
index 3e58ee26..1433fb85 100644
--- a/react-ui/src/pages/Experiment/experimentText/addExperimentModal.tsx
+++ b/react-ui/src/pages/Experiment/experimentText/addExperimentModal.tsx
@@ -145,7 +145,13 @@ function AddExperimentModal({
name="description"
rules={[{ required: true, message: '请输入实验描述' }]}
>
-
+
{
const { status, data } = response;
- // console.log('response', response);
- if (status >= 200 && status < 300 && data && (data instanceof Blob || data.code === 200)) {
- return response;
- } else {
- if (data && data.msg) {
- message.error(data.msg);
+ if (status >= 200 && status < 300) {
+ if (data && (data instanceof Blob || data.code === 200)) {
+ return response;
+ } else if (data && data.code === 401) {
+ clearSessionToken();
+ setRemoteMenu(null);
+ gotoLoginPage(false);
} else {
- message.error('请求失败');
+ message.error(data?.msg ?? '请求失败');
+ return Promise.reject(response);
}
+ } else {
+ message.error('请求失败');
return Promise.reject(response);
}
},
diff --git a/react-ui/src/services/session.ts b/react-ui/src/services/session.ts
index 44861d39..39b0ff84 100644
--- a/react-ui/src/services/session.ts
+++ b/react-ui/src/services/session.ts
@@ -1,8 +1,7 @@
-import { createIcon } from '@/utils/IconUtil';
import { MenuDataItem } from '@ant-design/pro-components';
import { request } from '@umijs/max';
import React, { lazy } from 'react';
-import { createFromIconfontCN } from '@ant-design/icons';
+
let remoteMenu: any = null;
export function getRemoteMenu() {
@@ -101,7 +100,7 @@ export function convertCompatRouters(childrens: API.RoutersMenuItem[]): any[] {
return {
path: item.path,
// icon:'icon-a-057_fenlei',
- icon: 'icon-'+item.meta.icon,
+ icon: 'icon-' + item.meta.icon,
// icon: item.meta.icon,
name: item.meta.title,
routes: item.children ? convertCompatRouters(item.children) : undefined,
diff --git a/react-ui/src/services/system/auth.ts b/react-ui/src/services/system/auth.ts
index 031b2ef3..e69e571e 100644
--- a/react-ui/src/services/system/auth.ts
+++ b/react-ui/src/services/system/auth.ts
@@ -28,8 +28,8 @@ export async function login(body: API.LoginParams, options?: Record
/** 退出登录接口 POST /api/login/outLogin */
export async function logout() {
- return request>('/api/logout', {
- method: 'delete',
+ return request>('/api/auth/logout', {
+ method: 'DELETE',
});
}
diff --git a/react-ui/src/utils/ui.tsx b/react-ui/src/utils/ui.tsx
index 51a74143..1ac54b1a 100644
--- a/react-ui/src/utils/ui.tsx
+++ b/react-ui/src/utils/ui.tsx
@@ -3,7 +3,9 @@
* @Date: 2024-04-19 14:42:51
* @Description: UI 公共方法
*/
+import { PageEnum } from '@/enums/pagesEnums';
import themes from '@/styles/theme.less';
+import { history } from '@umijs/max';
import { Modal, type ModalFuncProps, type UploadFile } from 'antd';
// 自定义 Confirm 弹框
@@ -43,3 +45,17 @@ export const getFileListFromEvent = (e: any) => {
return item;
});
};
+
+// 去登录页面
+export const gotoLoginPage = (toHome: boolean = true) => {
+ const { search, pathname } = window.location;
+ const urlParams = new URLSearchParams();
+ urlParams.append('redirect', pathname + search);
+ const newSearch = toHome ? '' : urlParams.toString();
+ if (window.location.pathname !== PageEnum.LOGIN) {
+ history.replace({
+ pathname: PageEnum.LOGIN,
+ search: newSearch,
+ });
+ }
+};