import { Item } from '@antv/g6/lib/types' ; import G from '@antv/g-canvas' ; import { Graph } from '../types' ; param { boolean } isOptimize param { Item } node const optimizeDrawingByNode = ( isOptimize , node ) => { const shapes = node . getContainer ( ) . get ( 'children' ) ; const keyShape = shapes . find ( ( item ) => item . isKeyShape ) ; keyShape . show ( ) ; shapes . forEach ( ( shape ) => { if ( isOptimize && shape !== keyShape ) { shape . hide ( ) ; } else { shape . show ( ) ; } } ) ; } ; param { object } graph param { boolean } isOptimize const optimizeDrawing = ( graph , isOptimize ) => { graph . getNodes ( ) . forEach ( ( node ) => { optimizeDrawingByNode ( isOptimize , node ) ; } ) ; /** 渲染 */ graph . autoPaint ( ) ; } ; export { optimizeDrawing , optimizeDrawingByNode } ;