From d35b7173079c30e462dcc3f270577ae6d51595e4 Mon Sep 17 00:00:00 2001 From: cp3hnu Date: Thu, 27 Mar 2025 11:39:05 +0800 Subject: [PATCH 1/3] =?UTF-8?q?chore:=20=E4=BC=98=E5=8C=96=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=97=B6=E9=95=BF=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- react-ui/src/utils/date.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/react-ui/src/utils/date.ts b/react-ui/src/utils/date.ts index 97e7f32d..33c8dda8 100644 --- a/react-ui/src/utils/date.ts +++ b/react-ui/src/utils/date.ts @@ -29,22 +29,30 @@ export const elapsedTime = (begin?: string | null, end?: string | null): string const hours = duration.hours(); const minutes = duration.minutes(); const seconds = duration.seconds(); + const elspsedArray = []; if (years !== 0) { - return `${years}年${months}个月`; + elspsedArray.push(`${years}年`); } if (months !== 0) { - return `${months}个月${days}天`; + elspsedArray.push(`${months}个月`); } if (days !== 0) { - return `${days}天${hours}小时`; + elspsedArray.push(`${days}天`); } if (hours !== 0) { - return `${hours}小时${minutes}分`; + elspsedArray.push(`${hours}小时`); } if (minutes !== 0) { - return `${minutes}分${seconds}秒`; + elspsedArray.push(`${minutes}分`); } - return `${seconds}秒`; + if (seconds !== 0) { + elspsedArray.push(`${seconds}秒`); + } + + if (elspsedArray.length === 0) { + return '0秒'; + } + return elspsedArray.slice(0, 2).join(''); }; /** From d428d0793680de01f972306e6fc6e4b6a5738f84 Mon Sep 17 00:00:00 2001 From: cp3hnu Date: Thu, 27 Mar 2025 11:40:11 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=B1=E8=B4=A5=E6=B2=A1=E6=9C=89=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- react-ui/src/requestConfig.ts | 39 ++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/react-ui/src/requestConfig.ts b/react-ui/src/requestConfig.ts index 06dd26b8..1b496981 100644 --- a/react-ui/src/requestConfig.ts +++ b/react-ui/src/requestConfig.ts @@ -53,7 +53,7 @@ export const requestConfig: RequestConfig = { ], responseInterceptors: [ [ - (response: AxiosResponse) => { + async (response: AxiosResponse) => { const { status, data, config } = response || {}; const options = config as RequestOptions; const skipErrorHandler = options?.skipErrorHandler; @@ -63,20 +63,45 @@ export const requestConfig: RequestConfig = { Loading.hide(); } if (status >= 200 && status < 300) { - if (status === 204) { + // 无内容或者无需验证 + if (status === 204 || skipValidating) { return response; - } else if (data && (skipValidating || data instanceof Blob || data.code === 200)) { + } + + if (data && data.code === 200) { + return response; + } + + // Blob 数据 + if (data && data instanceof Blob && data.size > 0) { + // 下载文件失败时,返回的是 JSON 数据,格式为:{code: 500, msg: "xxx"} + if (data.type === 'application/json') { + try { + const text = await data.text(); + const json = JSON.parse(text); + + if (json.code === 500) { + popupError(json.msg || '请求失败', skipErrorHandler); + return Promise.reject(json); + } + } catch (error) { + console.error('JSON 解析失败', error); + } + } return response; - } else if (data && data.code === 401) { + } + + // Token 失效 + if (data && data.code === 401) { clearSessionToken(); setRemoteMenu(null); gotoLoginPage(false); popupError('请重新登录'); return Promise.reject(response); - } else { - popupError(data?.msg ?? '请求失败', skipErrorHandler); - return Promise.reject(response); } + + popupError(data?.msg ?? '请求失败', skipErrorHandler); + return Promise.reject(response); } else { popupError('请求失败', skipErrorHandler); return Promise.reject(response); From 0a35cc79f41339abbfa9a6be2750959198343244 Mon Sep 17 00:00:00 2001 From: cp3hnu Date: Thu, 27 Mar 2025 11:41:58 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=B5=81=E6=B0=B4?= =?UTF-8?q?=E7=BA=BF=E5=88=A0=E9=99=A4=E4=B9=8B=E5=90=8E=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E4=BA=86=E4=B8=A4=E6=AC=A1=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ResourceVersion/index.tsx | 6 ++ react-ui/src/pages/Pipeline/index.jsx | 75 +++++++++---------- react-ui/src/utils/loading.tsx | 5 +- 3 files changed, 42 insertions(+), 44 deletions(-) diff --git a/react-ui/src/pages/Dataset/components/ResourceVersion/index.tsx b/react-ui/src/pages/Dataset/components/ResourceVersion/index.tsx index 3dbb3c40..18fbc3ee 100644 --- a/react-ui/src/pages/Dataset/components/ResourceVersion/index.tsx +++ b/react-ui/src/pages/Dataset/components/ResourceVersion/index.tsx @@ -1,3 +1,9 @@ +/* + * @Author: 赵伟 + * @Date: 2025-03-24 15:41:42 + * @Description: 版本文件列表 + */ + import KFIcon from '@/components/KFIcon'; import { ResourceData, diff --git a/react-ui/src/pages/Pipeline/index.jsx b/react-ui/src/pages/Pipeline/index.jsx index 205daca6..e78be54e 100644 --- a/react-ui/src/pages/Pipeline/index.jsx +++ b/react-ui/src/pages/Pipeline/index.jsx @@ -11,6 +11,7 @@ import { removeWorkflow, } from '@/services/pipeline/index.js'; import themes from '@/styles/theme.less'; +import { to } from '@/utils/promise'; import tableCellRender, { TableCellValueType } from '@/utils/table'; import { modalConfirm } from '@/utils/ui'; import { App, Button, ConfigProvider, Form, Input, Space, Table } from 'antd'; @@ -132,23 +133,38 @@ const Pipeline = () => { 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); - } - }); + onOk: async () => { + const { id } = record; + const [res] = await to(removeWorkflow(id)); + if (res) { + message.success('删除成功'); + // 如果是一页的唯一数据,删除后,请求第一页的数据 + // 否则直接刷新这一页的数据 + setPagination((prev) => { + return { + ...prev, + current: pipeList.length === 1 ? Math.max(1, prev.current - 1) : prev.current, + }; + }); + } + }, + }); + }; + + // 处理复制 + const handlePipelineCopy = (record) => { + modalConfirm({ + title: '确定复制该条流水线吗?', + okText: '确认', + cancelText: '取消', + isDelete: false, + onOk: async () => { + const { id } = record; + const [res] = await to(cloneWorkflow(id)); + if (res) { + message.success('复制成功'); + getList(); + } }, }); }; @@ -225,30 +241,7 @@ const Pipeline = () => { size="small" key="clone" icon={} - onClick={async () => { - modalConfirm({ - title: '确定复制该条流水线吗?', - okText: '确认', - cancelText: '取消', - isDelete: false, - onOk: () => { - cloneWorkflow(record.id).then((ret) => { - if (ret.code === 200) { - message.success('复制成功'); - getList(); - } else { - message.error('复制失败'); - } - }); - - // if (success) { - // if (actionRef.current) { - // actionRef.current.reload(); - // } - // } - }, - }); - }} + onClick={() => handlePipelineCopy(record)} > 复制 diff --git a/react-ui/src/utils/loading.tsx b/react-ui/src/utils/loading.tsx index 8486a6b9..0180a243 100644 --- a/react-ui/src/utils/loading.tsx +++ b/react-ui/src/utils/loading.tsx @@ -28,7 +28,7 @@ export class Loading { } const container = document.createElement('div'); container.id = 'loading'; - const rootContainer = document.body; //document.getElementsByTagName('main')[0]; + const rootContainer = document.body; // document.getElementsByTagName('main')[0]; rootContainer?.appendChild(container); const root = createRoot(container); const global = globalConfig(); @@ -69,10 +69,9 @@ export class Loading { static removeLoading() { this.clearRemoveTimeout(); - const rootContainer = document.body; //document.getElementsByTagName('main')[0]; const container = document.getElementById('loading'); if (container) { - rootContainer?.removeChild(container); + container.parentNode?.removeChild(container); } this.isShowing = false; }