1
This commit is contained in:
parent
dbbabdcca4
commit
8f5c05d16f
@ -1,14 +1,15 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { RouterProvider } from 'react-router-dom';
|
import { RouterProvider } from 'react-router-dom';
|
||||||
import { ConfigProvider } from 'antd';
|
import { ConfigProvider, App as AntdApp } from 'antd';
|
||||||
import zhCN from 'antd/locale/zh_CN';
|
import zhCN from 'antd/locale/zh_CN';
|
||||||
import router from './router';
|
import router from './router';
|
||||||
|
|
||||||
const App: React.FC = () => {
|
const App: React.FC = () => {
|
||||||
console.log('App');
|
|
||||||
return (
|
return (
|
||||||
<ConfigProvider locale={zhCN}>
|
<ConfigProvider locale={zhCN}>
|
||||||
<RouterProvider router={router} />
|
<AntdApp>
|
||||||
|
<RouterProvider router={router} />
|
||||||
|
</AntdApp>
|
||||||
</ConfigProvider>
|
</ConfigProvider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import React, {useState, useEffect} from 'react';
|
import React, {useState, useEffect} from 'react';
|
||||||
import {PageContainer} from '@ant-design/pro-layout';
|
import {PageContainer} from '@ant-design/pro-layout';
|
||||||
import {Button, message, Popconfirm, Select, Space} from 'antd';
|
import {Button, message, Popconfirm, Select, Space, App} from 'antd';
|
||||||
import {PlusOutlined, EditOutlined, DeleteOutlined} from '@ant-design/icons';
|
import {PlusOutlined, EditOutlined, DeleteOutlined} from '@ant-design/icons';
|
||||||
import {getDeploymentConfigPage, deleteDeploymentConfig} from './service';
|
import {getDeploymentConfigPage, deleteDeploymentConfig} from './service';
|
||||||
import {getEnvironmentList} from '../../Environment/List/service';
|
import {getEnvironmentList} from '../../Environment/List/service';
|
||||||
@ -18,6 +18,7 @@ const DeploymentConfigList: React.FC = () => {
|
|||||||
const [modalVisible, setModalVisible] = useState(false);
|
const [modalVisible, setModalVisible] = useState(false);
|
||||||
const [currentConfig, setCurrentConfig] = useState<DeploymentConfig>();
|
const [currentConfig, setCurrentConfig] = useState<DeploymentConfig>();
|
||||||
const actionRef = React.useRef<ActionType>();
|
const actionRef = React.useRef<ActionType>();
|
||||||
|
const {message: messageApi} = App.useApp();
|
||||||
|
|
||||||
// 获取环境列表
|
// 获取环境列表
|
||||||
const fetchEnvironments = async () => {
|
const fetchEnvironments = async () => {
|
||||||
@ -28,7 +29,7 @@ const DeploymentConfigList: React.FC = () => {
|
|||||||
setSelectedEnvId(data[0].id);
|
setSelectedEnvId(data[0].id);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
message.error('获取环境列表失败');
|
messageApi.error('获取环境列表失败');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -39,16 +40,16 @@ const DeploymentConfigList: React.FC = () => {
|
|||||||
const handleDelete = async (id: number) => {
|
const handleDelete = async (id: number) => {
|
||||||
try {
|
try {
|
||||||
await deleteDeploymentConfig(id);
|
await deleteDeploymentConfig(id);
|
||||||
message.success('删除成功');
|
messageApi.success('删除成功');
|
||||||
actionRef.current?.reload();
|
actionRef.current?.reload();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
message.error('删除失败');
|
messageApi.error('删除失败');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAdd = () => {
|
const handleAdd = () => {
|
||||||
if (!selectedEnvId) {
|
if (!selectedEnvId) {
|
||||||
message.warning('请先选择环境');
|
messageApi.warning('请先选择环境');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setCurrentConfig(undefined);
|
setCurrentConfig(undefined);
|
||||||
@ -213,18 +214,27 @@ const DeploymentConfigList: React.FC = () => {
|
|||||||
total: 0,
|
total: 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const queryParams: DeploymentConfigQueryParams = {
|
try {
|
||||||
pageSize: params.pageSize,
|
const queryParams: DeploymentConfigQueryParams = {
|
||||||
pageNum: params.current,
|
pageSize: params.pageSize,
|
||||||
envId: selectedEnvId,
|
pageNum: params.current,
|
||||||
enabled: params.enabled as boolean,
|
envId: selectedEnvId,
|
||||||
};
|
enabled: params.enabled as boolean,
|
||||||
const data = await getDeploymentConfigPage(queryParams);
|
};
|
||||||
return {
|
const data = await getDeploymentConfigPage(queryParams);
|
||||||
data: data.content || [],
|
return {
|
||||||
success: true,
|
data: data.content || [],
|
||||||
total: data.totalElements || 0,
|
success: true,
|
||||||
};
|
total: data.totalElements || 0,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
messageApi.error('获取部署配置列表失败');
|
||||||
|
return {
|
||||||
|
data: [],
|
||||||
|
success: false,
|
||||||
|
total: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user