diff --git a/react-ui/src/app.tsx b/react-ui/src/app.tsx index 7c026d3d..3666ff81 100644 --- a/react-ui/src/app.tsx +++ b/react-ui/src/app.tsx @@ -1,11 +1,14 @@ import RightContent from '@/components/RightContent'; import themes from '@/styles/theme.less'; +import { type GlobalInitialState } from '@/types'; +import { menuItemRender } from '@/utils/menuRender'; import type { Settings as LayoutSettings } from '@ant-design/pro-components'; import { RuntimeConfig, history } from '@umijs/max'; import { RuntimeAntdConfig } from 'umi'; import defaultSettings from '../config/defaultSettings'; import '../public/fonts/font.css'; import { getAccessToken } from './access'; +import ErrorBoundary from './components/ErrorBoundary'; import './dayjsConfig'; import { removeAllPageCacheState } from './hooks/pageCacheState'; import { @@ -16,14 +19,9 @@ import { setRemoteMenu, } from './services/session'; import './styles/menu.less'; -export { requestConfig as request } from './requestConfig'; -// const isDev = process.env.NODE_ENV === 'development'; -import { type GlobalInitialState } from '@/types'; -// import '@/utils/clipboard'; -import { menuItemRender } from '@/utils/menuRender'; -import ErrorBoundary from './components/ErrorBoundary'; import { needAuth } from './utils'; import { gotoLoginPage } from './utils/ui'; +export { requestConfig as request } from './requestConfig'; /** * @see https://umijs.org/zh-CN/plugins/plugin-initial-state diff --git a/react-ui/src/utils/clipboard.js b/react-ui/src/components/CopyingText/clipboard.js similarity index 100% rename from react-ui/src/utils/clipboard.js rename to react-ui/src/components/CopyingText/clipboard.js diff --git a/react-ui/src/pages/AutoML/components/CopyingText/index.less b/react-ui/src/components/CopyingText/index.less similarity index 100% rename from react-ui/src/pages/AutoML/components/CopyingText/index.less rename to react-ui/src/components/CopyingText/index.less diff --git a/react-ui/src/components/CopyingText/index.tsx b/react-ui/src/components/CopyingText/index.tsx new file mode 100644 index 00000000..5a87ebe3 --- /dev/null +++ b/react-ui/src/components/CopyingText/index.tsx @@ -0,0 +1,26 @@ +import KFIcon from '@/components/KFIcon'; +import { Tooltip } from 'antd'; +import styles from './index.less'; + +export type CopyingTextProps = { + text: string; +}; + +function CopyingText({ text }: CopyingTextProps) { + return ( +
+ {text} + + + +
+ ); +} + +export default CopyingText; diff --git a/react-ui/src/pages/AutoML/components/CopyingText/index.tsx b/react-ui/src/pages/AutoML/components/CopyingText/index.tsx deleted file mode 100644 index 586de40b..00000000 --- a/react-ui/src/pages/AutoML/components/CopyingText/index.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import KFIcon from '@/components/KFIcon'; -import { Typography } from 'antd'; -import styles from './index.less'; - -export type CopyingTextProps = { - text: string; -}; - -function CopyingText({ text }: CopyingTextProps) { - return ( -
- - {text} - - -
- ); -} - -export default CopyingText; diff --git a/react-ui/src/pages/AutoML/components/ExperimentList/index.tsx b/react-ui/src/pages/AutoML/components/ExperimentList/index.tsx index e2f9d31c..e187167f 100644 --- a/react-ui/src/pages/AutoML/components/ExperimentList/index.tsx +++ b/react-ui/src/pages/AutoML/components/ExperimentList/index.tsx @@ -93,17 +93,14 @@ function ExperimentList({ type }: ExperimentListProps) { const [res] = await to(request(record.id)); if (res) { message.success('删除成功'); - // 如果是一页的唯一数据,删除时,请求第一页的数据 + // 如果是一页的唯一数据,删除后,请求第一页的数据 // 否则直接刷新这一页的数据 - // 避免回到第一页 - if (tableData.length > 1) { - setPagination((prev) => ({ + setPagination((prev) => { + return { ...prev, - current: 1, - })); - } else { - getAutoMLList(); - } + current: tableData.length === 1 ? Math.max(1, prev.current! - 1) : prev.current, + }; + }); } }; diff --git a/react-ui/src/pages/CodeConfig/List/index.tsx b/react-ui/src/pages/CodeConfig/List/index.tsx index 3f567465..a1ccd09c 100644 --- a/react-ui/src/pages/CodeConfig/List/index.tsx +++ b/react-ui/src/pages/CodeConfig/List/index.tsx @@ -75,8 +75,15 @@ function CodeConfigList() { const deleteRecord = async (id: number) => { const [res] = await to(deleteCodeConfigReq(id)); if (res) { - getDataList(); message.success('删除成功'); + // 如果是一页的唯一数据,删除后,请求第一页的数据 + // 否则直接刷新这一页的数据 + setPagination((prev) => { + return { + ...prev, + current: dataList!.length === 1 ? Math.max(1, prev.current! - 1) : prev.current, + }; + }); } }; diff --git a/react-ui/src/pages/Dataset/components/ResourceList/index.tsx b/react-ui/src/pages/Dataset/components/ResourceList/index.tsx index 6549b9c1..2f1e8d4e 100644 --- a/react-ui/src/pages/Dataset/components/ResourceList/index.tsx +++ b/react-ui/src/pages/Dataset/components/ResourceList/index.tsx @@ -107,8 +107,15 @@ function ResourceList( const request = config.deleteRecord; const [res] = await to(request(params)); if (res) { - getDataList(); message.success('删除成功'); + // 如果是一页的唯一数据,删除后,请求第一页的数据 + // 否则直接刷新这一页的数据 + setPagination((prev) => { + return { + ...prev, + current: dataList!.length === 1 ? Math.max(1, prev.current! - 1) : prev.current, + }; + }); } }; diff --git a/react-ui/src/pages/DevelopmentEnvironment/List/index.tsx b/react-ui/src/pages/DevelopmentEnvironment/List/index.tsx index 4af043ba..cc90524d 100644 --- a/react-ui/src/pages/DevelopmentEnvironment/List/index.tsx +++ b/react-ui/src/pages/DevelopmentEnvironment/List/index.tsx @@ -80,17 +80,14 @@ function EditorList() { const [res] = await to(deleteEditorReq(id)); if (res) { message.success('删除成功'); - // 如果是一页的唯一数据,删除时,请求第一页的数据 + // 如果是一页的唯一数据,删除后,请求第一页的数据 // 否则直接刷新这一页的数据 - // 避免回到第一页 - if (tableData.length > 1) { - setPagination((prev) => ({ + setPagination((prev) => { + return { ...prev, - current: 1, - })); - } else { - getEditorList(); - } + current: tableData.length === 1 ? Math.max(1, prev.current! - 1) : prev.current, + }; + }); } }; diff --git a/react-ui/src/pages/Experiment/index.jsx b/react-ui/src/pages/Experiment/index.jsx index b3a288b1..91737c32 100644 --- a/react-ui/src/pages/Experiment/index.jsx +++ b/react-ui/src/pages/Experiment/index.jsx @@ -378,6 +378,31 @@ function Experiment() { getQueryByExperiment(expandedRowKeys, page); }; + // 处理删除 + const handleExperimentDelete = (record) => { + modalConfirm({ + title: '删除后,该实验将不可恢复', + content: '是否确认删除?', + onOk: () => { + deleteExperimentById(record.id).then((ret) => { + if (ret.code === 200) { + message.success('删除成功'); + // 如果是一页的唯一数据,删除后,请求第一页的数据 + // 否则直接刷新这一页的数据 + setPagination((prev) => { + return { + ...prev, + current: experimentList.length === 1 ? Math.max(1, prev.current - 1) : prev.current, + }; + }); + } else { + message.error(ret.msg); + } + }); + }, + }); + }; + const columns = [ { title: '实验名称', @@ -476,22 +501,7 @@ function Experiment() { size="small" key="batchRemove" icon={} - onClick={() => { - modalConfirm({ - title: '删除后,该实验将不可恢复', - content: '是否确认删除?', - onOk: () => { - deleteExperimentById(record.id).then((ret) => { - if (ret.code === 200) { - message.success('删除成功'); - getExperimentList(); - } else { - message.error(ret.msg); - } - }); - }, - }); - }} + onClick={() => handleExperimentDelete(record)} > 删除 @@ -500,6 +510,7 @@ function Experiment() { ), }, ]; + return (
diff --git a/react-ui/src/pages/Mirror/Info/index.tsx b/react-ui/src/pages/Mirror/Info/index.tsx index 4b8efafd..b08fcc06 100644 --- a/react-ui/src/pages/Mirror/Info/index.tsx +++ b/react-ui/src/pages/Mirror/Info/index.tsx @@ -117,17 +117,14 @@ function MirrorInfo() { const [res] = await to(deleteMirrorVersionReq(id)); if (res) { message.success('删除成功'); - // 如果是一页的唯一数据,删除时,请求第一页的数据 + // 如果是一页的唯一数据,删除后,请求第一页的数据 // 否则直接刷新这一页的数据 - // 避免回到第一页 - if (tableData.length === 1) { - setPagination((prev) => ({ + setPagination((prev) => { + return { ...prev, - current: 1, - })); - } else { - getMirrorVersionList(); - } + current: tableData.length === 1 ? Math.max(1, prev.current! - 1) : prev.current, + }; + }); } }; diff --git a/react-ui/src/pages/Mirror/List/index.tsx b/react-ui/src/pages/Mirror/List/index.tsx index 3c8481e2..1c74ddea 100644 --- a/react-ui/src/pages/Mirror/List/index.tsx +++ b/react-ui/src/pages/Mirror/List/index.tsx @@ -103,17 +103,14 @@ function MirrorList() { const [res] = await to(deleteMirrorReq(id)); if (res) { message.success('删除成功'); - // 如果是一页的唯一数据,删除时,请求第一页的数据 + // 如果是一页的唯一数据,删除后,请求第一页的数据 // 否则直接刷新这一页的数据 - // 避免回到第一页 - if (tableData.length > 1) { - setPagination((prev) => ({ + setPagination((prev) => { + return { ...prev, - current: 1, - })); - } else { - getMirrorList(); - } + current: tableData.length === 1 ? Math.max(1, prev.current! - 1) : prev.current, + }; + }); } }; diff --git a/react-ui/src/pages/ModelDeployment/List/index.tsx b/react-ui/src/pages/ModelDeployment/List/index.tsx index 50fe9b84..389931f2 100644 --- a/react-ui/src/pages/ModelDeployment/List/index.tsx +++ b/react-ui/src/pages/ModelDeployment/List/index.tsx @@ -119,17 +119,14 @@ function ModelDeployment() { const [res] = await to(deleteServiceReq(record.id)); if (res) { message.success('删除成功'); - // 如果是一页的唯一数据,删除时,请求第一页的数据 + // 如果是一页的唯一数据,删除后,请求第一页的数据 // 否则直接刷新这一页的数据 - // 避免回到第一页 - if (tableData.length > 1) { - setPagination((prev) => ({ + setPagination((prev) => { + return { ...prev, - current: 1, - })); - } else { - getServiceList(); - } + current: tableData.length === 1 ? Math.max(1, prev.current! - 1) : prev.current, + }; + }); } }; diff --git a/react-ui/src/pages/ModelDeployment/ServiceInfo/index.tsx b/react-ui/src/pages/ModelDeployment/ServiceInfo/index.tsx index 3c1ee8d3..a0cecfe0 100644 --- a/react-ui/src/pages/ModelDeployment/ServiceInfo/index.tsx +++ b/react-ui/src/pages/ModelDeployment/ServiceInfo/index.tsx @@ -132,18 +132,14 @@ function ServiceInfo() { const [res] = await to(deleteServiceVersionReq(record.id)); if (res) { message.success('删除成功'); - // 如果是一页的唯一数据,删除时,请求第一页的数据 - // 否则直接刷新这一页的数据,避免回到第一页 - if (tableData.length === 1) { - setPagination((prev) => ({ + // 如果是一页的唯一数据,删除后,请求第一页的数据 + // 否则直接刷新这一页的数据 + setPagination((prev) => { + return { ...prev, - current: 1, - })); - } else { - setPagination((prev) => ({ - ...prev, - })); - } + current: tableData.length === 1 ? Math.max(1, prev.current! - 1) : prev.current, + }; + }); getServiceInfo(); } }; diff --git a/react-ui/src/pages/Pipeline/index.jsx b/react-ui/src/pages/Pipeline/index.jsx index eb2db981..205daca6 100644 --- a/react-ui/src/pages/Pipeline/index.jsx +++ b/react-ui/src/pages/Pipeline/index.jsx @@ -127,6 +127,32 @@ const Pipeline = () => { } }; + // 处理删除 + const handlePipelineDelete = (record) => { + modalConfirm({ + title: '删除后,该流水线将不可恢复', + content: '是否确认删除?', + onOk: () => { + removeWorkflow(record.id).then((ret) => { + if (ret.code === 200) { + message.success('删除成功'); + // 如果是一页的唯一数据,删除后,请求第一页的数据 + // 否则直接刷新这一页的数据 + setPagination((prev) => { + return { + ...prev, + current: pipeList.length === 1 ? Math.max(1, prev.current - 1) : prev.current, + }; + }); + getList(); + } else { + message.error(ret.msg); + } + }); + }, + }); + }; + // 当前页面切换 const paginationChange = async (current, pageSize) => { setPagination({ @@ -238,28 +264,7 @@ const Pipeline = () => { size="small" key="batchRemove" icon={} - onClick={() => { - modalConfirm({ - title: '删除后,该流水线将不可恢复', - content: '是否确认删除?', - onOk: () => { - removeWorkflow(record.id).then((ret) => { - if (ret.code === 200) { - message.success('删除成功'); - getList(); - } else { - message.error(ret.msg); - } - }); - - // if (success) { - // if (actionRef.current) { - // actionRef.current.reload(); - // } - // } - }, - }); - }} + onClick={() => handlePipelineDelete(record)} > 删除 diff --git a/react-ui/src/pages/Workspace/components/TotalStatistics/index.less b/react-ui/src/pages/Workspace/components/TotalStatistics/index.less index 34aa2a67..8a409b82 100644 --- a/react-ui/src/pages/Workspace/components/TotalStatistics/index.less +++ b/react-ui/src/pages/Workspace/components/TotalStatistics/index.less @@ -7,7 +7,7 @@ // 媒体查询 @media screen and (max-width: 1600px) { - flex: 1 1 content; + flex: auto; } &__icon { @@ -24,8 +24,7 @@ &__count { color: @text-color; - font-weight: 700; - font-size: 25px; + font-size: 26px; font-family: DingTalk-JinBuTi; } } diff --git a/react-ui/src/pages/Workspace/index.less b/react-ui/src/pages/Workspace/index.less index 59ea0a44..addf2fcd 100644 --- a/react-ui/src/pages/Workspace/index.less +++ b/react-ui/src/pages/Workspace/index.less @@ -27,6 +27,7 @@ &__statistics { flex: none; + min-width: 431px; background: linear-gradient( 123.08deg, rgba(138, 138, 138, 0.06) 1.32%, @@ -36,7 +37,7 @@ // 媒体查询 @media screen and (max-width: 1600px) { - flex: 1 1 content; + flex: 1; } } }