diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx
index 23836d1f..81e8777f 100644
--- a/frontend/src/App.tsx
+++ b/frontend/src/App.tsx
@@ -1,14 +1,15 @@
import React from 'react';
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 router from './router';
const App: React.FC = () => {
- console.log('App');
return (
-
+
+
+
);
};
diff --git a/frontend/src/pages/Deploy/Deployment/List/index.tsx b/frontend/src/pages/Deploy/Deployment/List/index.tsx
index d7008be8..415a088a 100644
--- a/frontend/src/pages/Deploy/Deployment/List/index.tsx
+++ b/frontend/src/pages/Deploy/Deployment/List/index.tsx
@@ -1,6 +1,6 @@
import React, {useState, useEffect} from 'react';
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 {getDeploymentConfigPage, deleteDeploymentConfig} from './service';
import {getEnvironmentList} from '../../Environment/List/service';
@@ -18,6 +18,7 @@ const DeploymentConfigList: React.FC = () => {
const [modalVisible, setModalVisible] = useState(false);
const [currentConfig, setCurrentConfig] = useState();
const actionRef = React.useRef();
+ const {message: messageApi} = App.useApp();
// 获取环境列表
const fetchEnvironments = async () => {
@@ -28,7 +29,7 @@ const DeploymentConfigList: React.FC = () => {
setSelectedEnvId(data[0].id);
}
} catch (error) {
- message.error('获取环境列表失败');
+ messageApi.error('获取环境列表失败');
}
};
@@ -39,16 +40,16 @@ const DeploymentConfigList: React.FC = () => {
const handleDelete = async (id: number) => {
try {
await deleteDeploymentConfig(id);
- message.success('删除成功');
+ messageApi.success('删除成功');
actionRef.current?.reload();
} catch (error) {
- message.error('删除失败');
+ messageApi.error('删除失败');
}
};
const handleAdd = () => {
if (!selectedEnvId) {
- message.warning('请先选择环境');
+ messageApi.warning('请先选择环境');
return;
}
setCurrentConfig(undefined);
@@ -213,18 +214,27 @@ const DeploymentConfigList: React.FC = () => {
total: 0,
};
}
- const queryParams: DeploymentConfigQueryParams = {
- pageSize: params.pageSize,
- pageNum: params.current,
- envId: selectedEnvId,
- enabled: params.enabled as boolean,
- };
- const data = await getDeploymentConfigPage(queryParams);
- return {
- data: data.content || [],
- success: true,
- total: data.totalElements || 0,
- };
+ try {
+ const queryParams: DeploymentConfigQueryParams = {
+ pageSize: params.pageSize,
+ pageNum: params.current,
+ envId: selectedEnvId,
+ enabled: params.enabled as boolean,
+ };
+ const data = await getDeploymentConfigPage(queryParams);
+ return {
+ data: data.content || [],
+ success: true,
+ total: data.totalElements || 0,
+ };
+ } catch (error) {
+ messageApi.error('获取部署配置列表失败');
+ return {
+ data: [],
+ success: false,
+ total: 0,
+ };
+ }
}}
/>