import { SKLayer } from '../types' ; param layer const isTouMing = ( layer ) => { if ( ! [ 'rectangle' , 'triangle' , 'oval' , 'star' , 'polygon' ] . includes ( layer . _class ) ) { return false ; } if ( ! ( layer . style ?. fills ?. filter ( item => item . isEnabled ) . length === 0 ) ) { return false ; } return true ; } ; param layers const handleNotFillLayerOrder = ( layers ) : SKLayer [ ] => { layers . sort ( ( bLayer , aLayer ) => { const aLayerIsTouMing = isTouMing ( aLayer ) ; const bLayerIsTouMing = isTouMing ( bLayer ) ; if ( ! aLayerIsTouMing && bLayerIsTouMing && ! ( aLayer . frame . x <= bLayer . frame . x && aLayer . frame . y <= bLayer . frame . y && aLayer . frame . x + aLayer . frame . width >= bLayer . frame . x + bLayer . frame . width && aLayer . frame . y + aLayer . frame . height >= bLayer . frame . y + bLayer . frame . height ) ) { return - 1 ; } if ( aLayerIsTouMing && bLayerIsTouMing && ( aLayer . frame . x >= bLayer . frame . x && aLayer . frame . y >= bLayer . frame . y && aLayer . frame . x + aLayer . frame . width <= bLayer . frame . x + bLayer . frame . width && aLayer . frame . y + aLayer . frame . height <= bLayer . frame . y + bLayer . frame . height ) ) { return - 1 ; } return 0 ; } ) ; layers = layers . map ( ( layer ) => { if ( Array . isArray ( layer . layers ) ) { layer . layers = handleNotFillLayerOrder ( layer . layers ) ; } return layer ; } ) ; return layers ; } ; export default handleNotFillLayerOrder ;