Browse Source

fix: 修复积分和开发环境bug

pull/195/head
cp3hnu 10 months ago
parent
commit
8ca391ad04
6 changed files with 91 additions and 37 deletions
  1. +0
    -1
      react-ui/src/app.tsx
  2. +3
    -3
      react-ui/src/pages/DevelopmentEnvironment/Create/index.tsx
  3. +73
    -26
      react-ui/src/pages/DevelopmentEnvironment/List/index.tsx
  4. +5
    -5
      react-ui/src/pages/DevelopmentEnvironment/components/CreateMirrorModal/index.tsx
  5. +2
    -2
      react-ui/src/pages/Points/index.tsx
  6. +8
    -0
      react-ui/src/pages/System/User/edit.tsx

+ 0
- 1
react-ui/src/app.tsx View File

@@ -137,7 +137,6 @@ export const layout: RuntimeConfig['layout'] = ({ initialState }) => {
onClick: () => {
// 点击菜单项,删除所有的页面 state 缓存
removeAllPageCacheState();
// console.log('click menu');
},
},
...initialState?.settings,


+ 3
- 3
react-ui/src/pages/DevelopmentEnvironment/Create/index.tsx View File

@@ -104,16 +104,16 @@ function EditorCreate() {
<Row gutter={10}>
<Col span={10}>
<Form.Item
label="任务名称"
label="编辑器名称"
name="name"
rules={[
{
required: true,
message: '请输入任务名称',
message: '请输入编辑器名称',
},
]}
>
<Input placeholder="请输入任务名称" maxLength={64} showCount allowClear />
<Input placeholder="请输入编辑器名称" maxLength={64} showCount allowClear />
</Form.Item>
</Col>
</Row>


+ 73
- 26
react-ui/src/pages/DevelopmentEnvironment/List/index.tsx View File

@@ -7,6 +7,8 @@
import KFIcon from '@/components/KFIcon';
import { DevEditorStatus } from '@/enums';
import { useCacheState } from '@/hooks/useCacheState';
import { useComputingResource } from '@/hooks/useComputingResource';
import { DatasetData, ModelData } from '@/pages/Dataset/config';
import {
deleteEditorReq,
getEditorListReq,
@@ -14,6 +16,7 @@ import {
stopEditorReq,
} from '@/services/developmentEnvironment';
import themes from '@/styles/theme.less';
import { parseJsonText } from '@/utils';
import { openAntdModal } from '@/utils/modal';
import { to } from '@/utils/promise';
import SessionStorage from '@/utils/sessionStorage';
@@ -42,6 +45,10 @@ export type EditorData = {
update_by: string;
create_time: string;
url: string;
computing_resource_id: number;
dataset?: string | DatasetData;
model?: string | ModelData;
image?: string;
};

function EditorList() {
@@ -56,6 +63,7 @@ function EditorList() {
pageSize: 10,
},
);
const getResourceDescription = useComputingResource()[1];

// 获取编辑器列表
const getEditorList = useCallback(async () => {
@@ -66,6 +74,10 @@ function EditorList() {
const [res] = await to(getEditorListReq(params));
if (res && res.data) {
const { content = [], totalElements = 0 } = res.data;
content.forEach((item: EditorData) => {
item.dataset = typeof item.dataset === 'string' ? parseJsonText(item.dataset) : null;
item.model = typeof item.model === 'string' ? parseJsonText(item.model) : null;
});
setTableData(content);
setTotal(totalElements);
}
@@ -102,11 +114,18 @@ function EditorList() {

// 停止编辑器
const stopEditor = async (id: number) => {
const [res] = await to(stopEditorReq(id));
if (res) {
message.success('操作成功');
getEditorList();
}
modalConfirm({
title: '停止后,该编辑器将不可使用',
content: '是否确认停止?',
isDelete: false,
onOk: async () => {
const [res] = await to(stopEditorReq(id));
if (res) {
message.success('操作成功');
getEditorList();
}
},
});
};

// 制作镜像
@@ -165,44 +184,72 @@ function EditorList() {
title: '编辑器名称',
dataIndex: 'name',
key: 'name',
width: '30%',
render: (text, record) =>
record.url && record.status === DevEditorStatus.Running ? (
<a className="kf-table-row-link" onClick={(e) => gotoEditorPage(e, record)}>
{text}
</a>
) : (
<span>{text ?? '--'}</span>
),
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
width: '10%',
render: EditorStatusCell,
width: '20%',
render: (text, record, index) =>
record.url && record.status === DevEditorStatus.Running
? tableCellRender<EditorData>(true, TableCellValueType.Link, {
onClick: (record, e) => gotoEditorPage(e, record),
})(text, record, index)
: tableCellRender<EditorData>(true, TableCellValueType.Text)(text, record, index),
},
{
title: '资源',
title: '计算资源',
dataIndex: 'computing_resource',
key: 'computing_resource',
width: '20%',
width: 100,
render: tableCellRender(),
},
{
title: '资源规格',
dataIndex: 'computing_resource_id',
key: 'computing_resource_id',
width: '20%',
render: tableCellRender(true, TableCellValueType.Custom, {
format: getResourceDescription,
}),
},
{
title: '数据集',
dataIndex: ['dataset', 'showValue'],
key: 'dataset',
width: '15%',
render: tableCellRender(true),
},
{
title: '模型',
dataIndex: ['model', 'showValue'],
key: 'model',
width: '15%',
render: tableCellRender(true),
},
{
title: '镜像',
dataIndex: ['image'],
key: 'image',
width: '15%',
render: tableCellRender(true),
},
{
title: '创建者',
dataIndex: 'update_by',
key: 'update_by',
width: '20%',
render: tableCellRender(),
width: '15%',
render: tableCellRender(true),
},
{
title: '创建时间',
dataIndex: 'create_time',
key: 'create_time',
width: '20%',
width: 180,
render: tableCellRender(false, TableCellValueType.Date),
},
{
title: '状态',
dataIndex: 'status',
key: 'status',
width: 80,
render: EditorStatusCell,
},
{
title: '操作',
dataIndex: 'operation',


+ 5
- 5
react-ui/src/pages/DevelopmentEnvironment/components/CreateMirrorModal/index.tsx View File

@@ -20,7 +20,7 @@ function CreateMirrorModal({ envId, onOk, ...rest }: CreateMirrorModalProps) {
}),
);
if (res) {
message.success('创建成功,请到 “AI资产” - “个人镜像” 中查看');
message.success('创建成功,请到 “多形态资源库” - “个人镜像” 中查看');
onOk?.();
}
};
@@ -59,12 +59,12 @@ function CreateMirrorModal({ envId, onOk, ...rest }: CreateMirrorModalProps) {
<Input placeholder="请输入镜像名称" maxLength={64} showCount allowClear />
</Form.Item>
<Form.Item
label="镜像Tag"
label="镜像版本"
name="tag_name"
rules={[
{
required: true,
message: '请输入镜像Tag',
message: '请输入镜像版本',
},
{
pattern: /^[a-zA-Z0-9._-]+$/,
@@ -72,7 +72,7 @@ function CreateMirrorModal({ envId, onOk, ...rest }: CreateMirrorModalProps) {
},
]}
>
<Input placeholder="请输入镜像Tag" maxLength={64} showCount allowClear />
<Input placeholder="请输入镜像版本" maxLength={64} showCount allowClear />
</Form.Item>
<Form.Item
label="镜像描述"
@@ -87,7 +87,7 @@ function CreateMirrorModal({ envId, onOk, ...rest }: CreateMirrorModalProps) {
<Input.TextArea
placeholder="请输入镜像描述"
autoSize={{ minRows: 3, maxRows: 6 }}
maxLength={256}
maxLength={128}
showCount
allowClear
/>


+ 2
- 2
react-ui/src/pages/Points/index.tsx View File

@@ -188,7 +188,7 @@ function PointsDetail() {
render: tableCellRender(),
},
{
title: '描述',
title: '资源规格',
dataIndex: 'description',
key: 'description',
render: tableCellRender(true),
@@ -217,7 +217,7 @@ function PointsDetail() {
color: themes['primaryColor'],
},
{
value: 0,
value: 2,
label: '准备中',
color: themes['pendingColor'],
},


+ 8
- 0
react-ui/src/pages/System/User/edit.tsx View File

@@ -316,11 +316,19 @@ const UserForm: React.FC<UserFormProps> = (props) => {
label="算力积分"
placeholder="请输入算力积分"
colProps={{ xs: 24, md: 12, xl: 12 }}
max={100000}
min={0}
rules={[
{
required: true,
message: '请输入算力积分',
},
{
type: 'number',
min: 0,
max: 100000,
message: '请输入0 ~ 100000之间的数',
},
]}
/>
<ProFormTextArea


Loading…
Cancel
Save