From 85d505cd53904a9e9ca64dab430b2831085c4810 Mon Sep 17 00:00:00 2001
From: zdl <3489966805@qq.com>
Date: Thu, 30 Oct 2025 19:04:30 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20InvestmentCalendar?=
=?UTF-8?q?=20Ant=20Design=205.x=20API=20=E5=BA=9F=E5=BC=83=E8=AD=A6?=
=?UTF-8?q?=E5=91=8A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
## 问题
控制台出现 4 个 Ant Design API 废弃警告:
```
[antd: Calendar] `dateCellRender` is deprecated. Please use `cellRender` instead.
[antd: Modal] `visible` is deprecated. Please use `open` instead.
[antd: Modal] `bodyStyle` is deprecated. Please use `styles.body` instead.
[antd: Drawer] `visible` is deprecated. Please use `open` instead.
```
## 修复内容
### 1. Calendar API (Line 137, 687)
**旧 API**:
```javascript
const dateCellRender = (value) => {
const dateStr = value.format('YYYY-MM-DD');
// ...
};
```
**新 API (Ant Design 5.x)**:
```javascript
const cellRender = (current, info) => {
// 只处理日期单元格,月份单元格返回默认
if (info.type !== 'date') return info.originNode;
const dateStr = current.format('YYYY-MM-DD');
// ...
};
```
### 2. Modal API (Line 701, 766)
`visible` → `open`
```javascript
// 旧 API
// 新 API
```
### 3. Modal Styles API (Line 705)
`bodyStyle` → `styles.body`
```javascript
// 旧 API
// 新 API
```
### 4. Drawer API (Line 740)
`visible` → `open`
```javascript
// 旧 API
// 新 API
```
## 影响
- ✅ 消除 4 个 Ant Design API 废弃警告
- ✅ 兼容 Ant Design 5.x
- ✅ 功能不受影响
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude
---
.../components/InvestmentCalendar.js | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/src/views/Community/components/InvestmentCalendar.js b/src/views/Community/components/InvestmentCalendar.js
index 44dd765f..3df32c21 100644
--- a/src/views/Community/components/InvestmentCalendar.js
+++ b/src/views/Community/components/InvestmentCalendar.js
@@ -133,9 +133,12 @@ const InvestmentCalendar = () => {
loadEventCounts(currentMonth);
}, [currentMonth, loadEventCounts]);
- // 自定义日期单元格渲染
- const dateCellRender = (value) => {
- const dateStr = value.format('YYYY-MM-DD');
+ // 自定义日期单元格渲染(Ant Design 5.x API)
+ const cellRender = (current, info) => {
+ // 只处理日期单元格,月份单元格返回默认
+ if (info.type !== 'date') return info.originNode;
+
+ const dateStr = current.format('YYYY-MM-DD');
const dayEvents = eventCounts.find(item => item.date === dateStr);
if (dayEvents && dayEvents.count > 0) {
@@ -681,7 +684,7 @@ const InvestmentCalendar = () => {
>
setCurrentMonth(date)}
/>
@@ -695,11 +698,11 @@ const InvestmentCalendar = () => {
{selectedDate?.format('YYYY年MM月DD日')} 投资事件
}
- visible={modalVisible}
+ open={modalVisible}
onCancel={() => setModalVisible(false)}
width={1200}
footer={null}
- bodyStyle={{ padding: '24px' }}
+ styles={{ body: { padding: '24px' } }}
zIndex={1500}
>
@@ -734,7 +737,7 @@ const InvestmentCalendar = () => {
placement="right"
width={600}
onClose={() => setDetailDrawerVisible(false)}
- visible={detailDrawerVisible}
+ open={detailDrawerVisible}
zIndex={1500}
>
{selectedDetail?.content?.type === 'citation' ? (
@@ -760,7 +763,7 @@ const InvestmentCalendar = () => {
)}
}
- visible={stockModalVisible}
+ open={stockModalVisible}
onCancel={() => {
setStockModalVisible(false);
setExpandedReasons({}); // 清理展开状态