Browse Source

Merge pull request '合并dev-zw' (#191) from dev-zw into dev

dev-active_learn
cp3hnu 10 months ago
parent
commit
9a2b950dd9
5 changed files with 88 additions and 57 deletions
  1. +6
    -0
      react-ui/src/pages/Dataset/components/ResourceVersion/index.tsx
  2. +34
    -41
      react-ui/src/pages/Pipeline/index.jsx
  3. +32
    -7
      react-ui/src/requestConfig.ts
  4. +14
    -6
      react-ui/src/utils/date.ts
  5. +2
    -3
      react-ui/src/utils/loading.tsx

+ 6
- 0
react-ui/src/pages/Dataset/components/ResourceVersion/index.tsx View File

@@ -1,3 +1,9 @@
/*
* @Author: 赵伟
* @Date: 2025-03-24 15:41:42
* @Description: 版本文件列表
*/

import KFIcon from '@/components/KFIcon'; import KFIcon from '@/components/KFIcon';
import { import {
ResourceData, ResourceData,


+ 34
- 41
react-ui/src/pages/Pipeline/index.jsx View File

@@ -11,6 +11,7 @@ import {
removeWorkflow, removeWorkflow,
} from '@/services/pipeline/index.js'; } from '@/services/pipeline/index.js';
import themes from '@/styles/theme.less'; import themes from '@/styles/theme.less';
import { to } from '@/utils/promise';
import tableCellRender, { TableCellValueType } from '@/utils/table'; import tableCellRender, { TableCellValueType } from '@/utils/table';
import { modalConfirm } from '@/utils/ui'; import { modalConfirm } from '@/utils/ui';
import { App, Button, ConfigProvider, Form, Input, Space, Table } from 'antd'; import { App, Button, ConfigProvider, Form, Input, Space, Table } from 'antd';
@@ -132,23 +133,38 @@ const Pipeline = () => {
modalConfirm({ modalConfirm({
title: '删除后,该流水线将不可恢复', title: '删除后,该流水线将不可恢复',
content: '是否确认删除?', 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" size="small"
key="clone" key="clone"
icon={<KFIcon type="icon-fuzhi" />} icon={<KFIcon type="icon-fuzhi" />}
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)}
> >
复制 复制
</Button> </Button>


+ 32
- 7
react-ui/src/requestConfig.ts View File

@@ -53,7 +53,7 @@ export const requestConfig: RequestConfig = {
], ],
responseInterceptors: [ responseInterceptors: [
[ [
(response: AxiosResponse) => {
async (response: AxiosResponse) => {
const { status, data, config } = response || {}; const { status, data, config } = response || {};
const options = config as RequestOptions; const options = config as RequestOptions;
const skipErrorHandler = options?.skipErrorHandler; const skipErrorHandler = options?.skipErrorHandler;
@@ -63,20 +63,45 @@ export const requestConfig: RequestConfig = {
Loading.hide(); Loading.hide();
} }
if (status >= 200 && status < 300) { if (status >= 200 && status < 300) {
if (status === 204) {
// 无内容或者无需验证
if (status === 204 || skipValidating) {
return response; 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; return response;
} else if (data && data.code === 401) {
}

// Token 失效
if (data && data.code === 401) {
clearSessionToken(); clearSessionToken();
setRemoteMenu(null); setRemoteMenu(null);
gotoLoginPage(false); gotoLoginPage(false);
popupError('请重新登录'); popupError('请重新登录');
return Promise.reject(response); return Promise.reject(response);
} else {
popupError(data?.msg ?? '请求失败', skipErrorHandler);
return Promise.reject(response);
} }

popupError(data?.msg ?? '请求失败', skipErrorHandler);
return Promise.reject(response);
} else { } else {
popupError('请求失败', skipErrorHandler); popupError('请求失败', skipErrorHandler);
return Promise.reject(response); return Promise.reject(response);


+ 14
- 6
react-ui/src/utils/date.ts View File

@@ -29,22 +29,30 @@ export const elapsedTime = (begin?: string | null, end?: string | null): string
const hours = duration.hours(); const hours = duration.hours();
const minutes = duration.minutes(); const minutes = duration.minutes();
const seconds = duration.seconds(); const seconds = duration.seconds();
const elspsedArray = [];
if (years !== 0) { if (years !== 0) {
return `${years}年${months}个月`;
elspsedArray.push(`${years}年`);
} }
if (months !== 0) { if (months !== 0) {
return `${months}个月${days}天`;
elspsedArray.push(`${months}个月`);
} }
if (days !== 0) { if (days !== 0) {
return `${days}天${hours}小时`;
elspsedArray.push(`${days}天`);
} }
if (hours !== 0) { if (hours !== 0) {
return `${hours}小时${minutes}分`;
elspsedArray.push(`${hours}小时`);
} }
if (minutes !== 0) { 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('');
}; };


/** /**


+ 2
- 3
react-ui/src/utils/loading.tsx View File

@@ -28,7 +28,7 @@ export class Loading {
} }
const container = document.createElement('div'); const container = document.createElement('div');
container.id = 'loading'; container.id = 'loading';
const rootContainer = document.body; //document.getElementsByTagName('main')[0];
const rootContainer = document.body; // document.getElementsByTagName('main')[0];
rootContainer?.appendChild(container); rootContainer?.appendChild(container);
const root = createRoot(container); const root = createRoot(container);
const global = globalConfig(); const global = globalConfig();
@@ -69,10 +69,9 @@ export class Loading {


static removeLoading() { static removeLoading() {
this.clearRemoveTimeout(); this.clearRemoveTimeout();
const rootContainer = document.body; //document.getElementsByTagName('main')[0];
const container = document.getElementById('loading'); const container = document.getElementById('loading');
if (container) { if (container) {
rootContainer?.removeChild(container);
container.parentNode?.removeChild(container);
} }
this.isShowing = false; this.isShowing = false;
} }


Loading…
Cancel
Save