From d296b0919cc321afca09ad9a28bed77ad56c903a Mon Sep 17 00:00:00 2001 From: zdl <3489966805@qq.com> Date: Fri, 5 Dec 2025 13:09:38 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=97=A5=E5=8E=86=E8=A7=86?= =?UTF-8?q?=E5=9B=BE=E7=A7=BB=E9=99=A4=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=8C=E4=BB=85=E4=BF=9D=E7=95=99=E6=9F=A5=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除删除按钮和 handleDeleteEvent 函数 - 移除未使用的导入(FiTrash2, IconButton, logger, getApiBase, toast, loadAllData) - 日历视图现在只用于查看事件,不支持编辑操作 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../Dashboard/components/CalendarPanel.tsx | 121 +----------------- 1 file changed, 1 insertion(+), 120 deletions(-) diff --git a/src/views/Dashboard/components/CalendarPanel.tsx b/src/views/Dashboard/components/CalendarPanel.tsx index 230dd4d2..947b940e 100644 --- a/src/views/Dashboard/components/CalendarPanel.tsx +++ b/src/views/Dashboard/components/CalendarPanel.tsx @@ -8,7 +8,6 @@ import { Box, Button, Badge, - IconButton, Flex, Modal, ModalOverlay, @@ -23,16 +22,12 @@ import { Text, Spinner, Center, - Tooltip, Icon, Tag, TagLabel, TagLeftIcon, } from '@chakra-ui/react'; import { - FiPlus, - FiEdit2, - FiTrash2, FiStar, FiTrendingUp, } from 'react-icons/fi'; @@ -45,10 +40,7 @@ import dayjs, { Dayjs } from 'dayjs'; import 'dayjs/locale/zh-cn'; import { usePlanningData } from './PlanningContext'; -import { EventFormModal } from './EventFormModal'; import type { InvestmentEvent } from '@/types'; -import { logger } from '@/utils/logger'; -import { getApiBase } from '@/utils/apiConfig'; dayjs.locale('zh-cn'); @@ -74,17 +66,13 @@ interface CalendarEvent { export const CalendarPanel: React.FC = () => { const { allEvents, - loadAllData, loading, - toast, borderColor, secondaryText, } = usePlanningData(); // 详情弹窗 const { isOpen, onOpen, onClose } = useDisclosure(); - // 添加弹窗状态 - const [isAddModalOpen, setIsAddModalOpen] = useState(false); const [selectedDate, setSelectedDate] = useState(null); const [selectedDateEvents, setSelectedDateEvents] = useState([]); @@ -129,61 +117,6 @@ export const CalendarPanel: React.FC = () => { onOpen(); }; - // 打开添加弹窗 - const handleOpenAddModal = (): void => { - onClose(); // 先关闭详情弹窗 - setIsAddModalOpen(true); - }; - - // 关闭添加弹窗 - const handleCloseAddModal = (): void => { - setIsAddModalOpen(false); - }; - - // 删除事件 - const handleDeleteEvent = async (eventId: number): Promise => { - if (!eventId) { - logger.warn('CalendarPanel', '删除事件失败: 缺少事件 ID', { eventId }); - toast({ - title: '无法删除', - description: '缺少事件 ID', - status: 'error', - duration: 3000, - }); - return; - } - try { - const base = getApiBase(); - - const response = await fetch(base + `/api/account/calendar/events/${eventId}`, { - method: 'DELETE', - credentials: 'include', - }); - - if (response.ok) { - logger.info('CalendarPanel', '删除事件成功', { eventId }); - toast({ - title: '删除成功', - status: 'success', - duration: 2000, - }); - loadAllData(); - } - } catch (error) { - logger.error('CalendarPanel', 'handleDeleteEvent', error, { eventId }); - toast({ - title: '删除失败', - status: 'error', - duration: 3000, - }); - } - }; - - // 查看事件详情(关闭弹窗) - const handleViewDetails = (): void => { - onClose(); - }; - return ( {loading ? ( @@ -228,17 +161,7 @@ export const CalendarPanel: React.FC = () => { {selectedDateEvents.length === 0 ? (
- - 当天没有事件 - - + 当天没有事件
) : ( @@ -273,30 +196,6 @@ export const CalendarPanel: React.FC = () => { )} - - {!event.source || event.source === 'user' ? ( - <> - - } - size="sm" - variant="ghost" - colorScheme="blue" - onClick={() => handleViewDetails()} - aria-label="查看详情" - /> - - } - size="sm" - variant="ghost" - colorScheme="red" - onClick={() => handleDeleteEvent(event.id)} - aria-label="删除事件" - /> - - ) : null} - {event.description && ( @@ -328,24 +227,6 @@ export const CalendarPanel: React.FC = () => { )} - {/* 使用通用弹窗组件 - 添加事件 */} -
); };