From ba65c5f3ad06926c5a65b59e88c09755d131f84a Mon Sep 17 00:00:00 2001 From: XiiTang Date: Mon, 12 Jan 2026 11:29:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=B9=B4=E5=BA=A6?= =?UTF-8?q?=E6=8A=A5=E5=91=8A=E7=9A=84=E8=87=AA=E5=AE=9A=E4=B9=89=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/AnnualReportWindow.tsx | 35 +++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/pages/AnnualReportWindow.tsx b/src/pages/AnnualReportWindow.tsx index e29f684..bf105f3 100644 --- a/src/pages/AnnualReportWindow.tsx +++ b/src/pages/AnnualReportWindow.tsx @@ -1,5 +1,5 @@ import { useState, useEffect, useRef } from 'react' -import { Loader2, Download, Image, Check, X } from 'lucide-react' +import { Loader2, Download, Image, Check, X, SlidersHorizontal } from 'lucide-react' import html2canvas from 'html2canvas' import { useThemeStore } from '../stores/themeStore' import './AnnualReportWindow.scss' @@ -249,6 +249,7 @@ function AnnualReportWindow() { const [fabOpen, setFabOpen] = useState(false) const [loadingProgress, setLoadingProgress] = useState(0) const [loadingStage, setLoadingStage] = useState('正在初始化...') + const [exportMode, setExportMode] = useState<'separate' | 'long'>('separate') const { currentTheme, themeMode } = useThemeStore() @@ -490,7 +491,7 @@ function AnnualReportWindow() { } // 导出整个报告为长图 - const exportFullReport = async () => { + const exportFullReport = async (filterIds?: Set) => { if (!containerRef.current) { return } @@ -516,6 +517,16 @@ function AnnualReportWindow() { el.style.padding = '40px 0' }) + // 如果有筛选,隐藏未选中的板块 + if (filterIds) { + const available = getAvailableSections() + available.forEach(s => { + if (!filterIds.has(s.id) && s.ref.current) { + s.ref.current.style.display = 'none' + } + }) + } + // 修复词云导出问题 const wordCloudInner = container.querySelector('.word-cloud-inner') as HTMLElement const wordTags = container.querySelectorAll('.word-tag') as NodeListOf @@ -584,7 +595,7 @@ function AnnualReportWindow() { const dataUrl = outputCanvas.toDataURL('image/png') const link = document.createElement('a') - link.download = `${reportData?.year}年度报告.png` + link.download = `${reportData?.year}年度报告${filterIds ? '_自定义' : ''}.png` link.href = dataUrl document.body.appendChild(link) link.click() @@ -607,6 +618,13 @@ function AnnualReportWindow() { return } + if (exportMode === 'long') { + setShowExportModal(false) + await exportFullReport(selectedSections) + setSelectedSections(new Set()) + return + } + setIsExporting(true) setShowExportModal(false) @@ -735,9 +753,12 @@ function AnnualReportWindow() { {/* 浮动操作按钮 */}
- + @@ -765,7 +786,7 @@ function AnnualReportWindow() {
setShowExportModal(false)}>
e.stopPropagation()}>
-

选择要导出的板块

+

{exportMode === 'long' ? '自定义导出长图' : '选择要导出的板块'}

@@ -793,7 +814,7 @@ function AnnualReportWindow() { onClick={exportSelectedSections} disabled={selectedSections.size === 0} > - 导出 {selectedSections.size > 0 ? `(${selectedSections.size})` : ''} + {exportMode === 'long' ? '生成长图' : '导出'} {selectedSections.size > 0 ? `(${selectedSections.size})` : ''}
@@ -838,7 +859,7 @@ function AnnualReportWindow() { 你发出 {formatNumber(topFriend.sentCount)} 条 · TA发来 {formatNumber(topFriend.receivedCount)}

-
+

在一起,就可以