统一全系统资源加载、轻量趋势与缓存恢复
This commit is contained in:
@@ -16,6 +16,7 @@ import {
|
||||
visualUnitLabel,
|
||||
} from './analysisVisualsModel';
|
||||
import type { AnalysisVisual } from './analysisVisualsModel';
|
||||
import { useDelayedIndicator } from './useDelayedBusy';
|
||||
import { analysisVisualCumulativeShares, analysisVisualShares, analysisVisualTypeLabel } from './analysisVisualPresentation';
|
||||
import './analysis-visuals.css';
|
||||
|
||||
@@ -126,9 +127,11 @@ export function AnalysisVisualCard({ visual, beforeExport, loadRuntime = loadAna
|
||||
const [nearViewport, setNearViewport] = useState(false);
|
||||
const [chartReady, setChartReady] = useState(false);
|
||||
const [chartLoading, setChartLoading] = useState(false);
|
||||
const showChartLoading = useDelayedIndicator(chartLoading, 150);
|
||||
const [chartError, setChartError] = useState('');
|
||||
const [dataOpen, setDataOpen] = useState(false);
|
||||
const [exporting, setExporting] = useState(false);
|
||||
const showExporting = useDelayedIndicator(exporting, 150);
|
||||
const [exportError, setExportError] = useState('');
|
||||
const [themeRevision, setThemeRevision] = useState(0);
|
||||
const [renderAttempt, setRenderAttempt] = useState(0);
|
||||
@@ -312,9 +315,9 @@ export function AnalysisVisualCard({ visual, beforeExport, loadRuntime = loadAna
|
||||
<Button size="small" icon={<TableOutlined />} onClick={openData}>查看数据</Button>
|
||||
<Dropdown
|
||||
trigger={['click']}
|
||||
menu={{ items: [{ key: 'png', icon: <DownloadOutlined />, label: exporting ? '正在导出…' : '下载 PNG', disabled: !visual.chartable || exporting, onClick: () => { void download(); } }] }}
|
||||
menu={{ items: [{ key: 'png', icon: <DownloadOutlined />, label: showExporting ? '正在导出…' : '下载 PNG', disabled: !visual.chartable || exporting, onClick: () => { void download(); } }] }}
|
||||
>
|
||||
<Button size="small" aria-label="更多图表操作" icon={exporting ? <span className="analysis-visual-spinner" aria-hidden="true" /> : <MoreOutlined />} />
|
||||
<Button size="small" aria-label="更多图表操作" icon={showExporting ? <span className="analysis-visual-spinner" aria-hidden="true" /> : <MoreOutlined />} />
|
||||
</Dropdown>
|
||||
</div>
|
||||
</header>
|
||||
@@ -337,7 +340,7 @@ export function AnalysisVisualCard({ visual, beforeExport, loadRuntime = loadAna
|
||||
style={visual.type === 'heatmap' ? { minWidth: Math.max(380, visual.categories.length * 62 + 160) }
|
||||
: visual.type === 'pareto' ? { minWidth: Math.max(600, visual.categories.length * 90 + 180) } : undefined} />
|
||||
{!nearViewport && <div className="analysis-visual-placeholder">图表将在进入视口时加载</div>}
|
||||
{nearViewport && chartLoading && <div className="analysis-visual-placeholder" role="status">正在加载图表…</div>}
|
||||
{nearViewport && showChartLoading && <div className="analysis-visual-placeholder" role="status">正在加载图表…</div>}
|
||||
{chartError && <div className="analysis-visual-chart-error" role="status">{chartError}
|
||||
<Button size="small" loading={retrying || chartLoading} onKeyDown={event => event.stopPropagation()}
|
||||
onClick={event => { event.stopPropagation(); void retryChart(); }}>重试图表</Button>
|
||||
|
||||
Reference in New Issue
Block a user