import { DLaysr } from '../types' ; param { Object } layer const isSingleText = ( layer ) => { if ( layer . type != "Text" ) { return false ; } if ( ! layer . style ) { return false ; } if ( layer . style . borderRadius || layer . structure . border || layer . style . background . color || layer . style . background . image || ( layer . structure . height && layer . style . textStyle . fontSize && layer . style . textStyle . fontSize <= layer . structure . height * 0.5 ) ) { return false ; } return true ; } ; export default ( data ) => { const isM = [ 375 , 750 ] . includes ( data [ 0 ] . structure . width ) ; data [ 0 ] . style . width = data [ 0 ] . structure . width ; data [ 0 ] . style . height = data [ 0 ] . structure . height ; data [ 0 ] . style . overflow = 'hidden' ; if ( ! isM ) { data [ 0 ] . style . position = 'absolute' ; data [ 0 ] . style = { ... data [ 0 ] . style , position : 'absolute' , left : '50%' , top : 0 , marginLeft : - Math . round ( data [ 0 ] . structure . width * 0.5 ) } ; } else { data [ 0 ] . style . position = 'relative' ; } const childLayerList = data [ 0 ] . children . map ( item => { item . style = { ... item . style , position : 'absolute' , left : Math . round ( item . structure . x ) , top : Math . round ( item . structure . y ) , width : item . structure . width , height : item . structure . height , } ; /**
         * 单行文本不设置宽度
         */ if ( isSingleText ( item ) ) { item . style . width = 'auto' ; } return item ; } ) ; return [ { ... data [ 0 ] , children : childLayerList } ] ; } ;