perf(web): manualChunks 拆分 heavy deps + lazy ProcessDesigner/ProcessViewer
Some checks failed
CI / rust-check (push) Has been cancelled
CI / rust-test (push) Has been cancelled
CI / frontend-build (push) Has been cancelled
CI / security-audit (push) Has been cancelled

- vite.config.ts 添加 vendor-charts/plots/graphs, vendor-flow, vendor-editor 独立 chunk
- vendor-antd 从 3000kB 降至 1532kB,charts 独立 1459kB
- ProcessDesigner/ProcessViewer 改为 React.lazy 按需加载
- 移除 PluginGraphPage 遗留的 animFrameRef 未使用变量
This commit is contained in:
iven
2026-04-27 10:11:12 +08:00
parent af44476c0f
commit 47df2e2aa6
4 changed files with 26 additions and 12 deletions

View File

@@ -59,7 +59,6 @@ export function PluginGraphPage() {
const { token } = theme.useToken();
const canvasRef = useRef<HTMLCanvasElement>(null);
const containerRef = useRef<HTMLDivElement>(null);
const animFrameRef = useRef<number>(0);
const nodePositionsRef = useRef<Map<string, NodePosition>>(new Map());
const visibleNodesRef = useRef<GraphNode[]>([]);
const visibleEdgesRef = useRef<GraphEdge[]>([]);

View File

@@ -1,5 +1,5 @@
import { useEffect, useCallback, useState, useRef } from 'react';
import { Button, message, Modal, Table, Tag } from 'antd';
import { useEffect, useCallback, useState, useRef, lazy, Suspense } from 'react';
import { Button, message, Modal, Spin, Table, Tag } from 'antd';
import { EyeOutlined, PauseCircleOutlined, PlayCircleOutlined, StopOutlined } from '@ant-design/icons';
import type { ColumnsType } from 'antd/es/table';
import {
@@ -10,7 +10,8 @@ import {
type ProcessInstanceInfo,
} from '../../api/workflowInstances';
import { getProcessDefinition, type NodeDef, type EdgeDef } from '../../api/workflowDefinitions';
import ProcessViewer from './ProcessViewer';
const ProcessViewer = lazy(() => import('./ProcessViewer'));
import { useThemeMode } from '../../hooks/useThemeMode';
const statusStyles: Record<string, { bg: string; color: string; text: string }> = {
@@ -289,7 +290,9 @@ export default function InstanceMonitor() {
width={720}
loading={viewerLoading}
>
<ProcessViewer nodes={viewerNodes} edges={viewerEdges} activeNodeIds={activeNodeIds} />
<Suspense fallback={<div style={{ textAlign: 'center', padding: 40 }}><Spin /></div>}>
<ProcessViewer nodes={viewerNodes} edges={viewerEdges} activeNodeIds={activeNodeIds} />
</Suspense>
</Modal>
</>
);

View File

@@ -1,5 +1,5 @@
import { useEffect, useState, useCallback } from 'react';
import { Button, message, Modal, Space, Table, Tag } from 'antd';
import { useEffect, useState, useCallback, lazy, Suspense } from 'react';
import { Button, message, Modal, Space, Spin, Table, Tag } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import type { ColumnsType } from 'antd/es/table';
import {
@@ -10,7 +10,8 @@ import {
type ProcessDefinitionInfo,
type CreateProcessDefinitionRequest,
} from '../../api/workflowDefinitions';
import ProcessDesigner from './ProcessDesigner';
const ProcessDesigner = lazy(() => import('./ProcessDesigner'));
import { useThemeMode } from '../../hooks/useThemeMode';
const statusColors: Record<string, { bg: string; color: string; text: string }> = {
@@ -190,10 +191,12 @@ export default function ProcessDefinitions() {
width={1200}
destroyOnClose
>
<ProcessDesigner
definitionId={editingId}
onSave={handleSave}
/>
<Suspense fallback={<div style={{ textAlign: 'center', padding: 40 }}><Spin /></div>}>
<ProcessDesigner
definitionId={editingId}
onSave={handleSave}
/>
</Suspense>
</Modal>
</>
);