Migrate MindMap to functional API pattern with Preact in ai directory#301
Migrate MindMap to functional API pattern with Preact in ai directory#301
Conversation
|
Co-authored-by: hustcc <[email protected]>
Co-authored-by: hustcc <[email protected]>
Co-authored-by: hustcc <[email protected]>
Co-authored-by: hustcc <[email protected]>
|
🎊 PR Preview c7394cf has been successfully built and deployed to https://antvis-GPT-Vis-preview-playground-pr-301.surge.sh 🕐 Build time: 0.01s 🤖 By surge-preview |
|
@copilot 颜色上不对。具体是以下代码不对: {
...(prev.find((transform) => (transform as any).key === 'assign-color-by-branch') ||
({} as any)),
type: 'assign-color-by-branch',
colors: THEME_COLORS[theme], // 这里不对
},应该改成: export const G6THEME_MAP: any = {
default: {
type: 'assign-color-by-branch',
colors: DEFAULT_COLOR_PALETTE,
},
academy: {
type: 'assign-color-by-branch',
colors: ACADEMY_COLOR_PALETTE,
},
};然后在 src/ai/vis/mind-map/index.ts 中使用的时候: {
...(prev.find((transform) => (transform as any).key === 'assign-color-by-branch') ||
({} as any)),
...G6THEME_MAP[theme], // 这里
},可以将 G6THEME_MAP 变量上存储到 src/ai/util/theme 中,后续其他关系图也能用到。 |
Co-authored-by: hustcc <[email protected]>
... Fixed in commit 7058d2b. Changes made:
The colors now correctly use the standard palette definitions (DEFAULT_COLOR_PALETTE and ACADEMY_COLOR_PALETTE). |
|
@copilot 试试下面两个改动。
|
Co-authored-by: hustcc <[email protected]>
Fixed in commit e1a22fb. Changes made:
Bundle size reduced from 2,934.94 KB to 2,805.72 KB (~129 KB reduction in main bundle). The MindMap components continue to work correctly with all themes: |
|
@copilot 增加 behaviors: 'zoom-canvas'。 |
Co-authored-by: hustcc <[email protected]>




Refactors MindMap from React component to functional factory pattern following the ai directory architecture for GPT-Vis 1.0, using Preact for optimized bundle size.
Changes
Core Implementation
render()anddestroy()methods. Uses Preact/compat to render @ant-design/graphs MindMap component with reduced bundle size.visTreeData2GraphData,visGraphData2GraphData)G6THEME_MAPfor graph component theme configuration (can be reused by other graph components)API Surface
Playground
@preact/preset-viteplugin for React-to-Preact aliasingBundle Size Optimization
Interactions
'drag-canvas'for panning and'zoom-canvas'for zooming (mouse wheel/touch gestures)Usage
Implementation Notes
G6THEME_MAPpattern fromsrc/ai/util/theme.ts(matches existing React component behavior)G6THEME_MAPcan be reused by other graph components (OrganizationChart, IndentedTree, FishboneDiagram, etc.)@preact/preset-viteautomatically handles React-to-Preact aliasing in the playgroundScreenshots
Three working examples showing hierarchical mind maps with correct color palettes, Chinese text rendering, theme support, and interactive zoom/pan capabilities, now powered by Preact for smaller bundle size.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.