@@ -51,7 +51,8 @@ class Backpack extends React.Component {
5151 'handleMouseLeave' ,
5252 'handleBlockDragEnd' ,
5353 'handleBlockDragUpdate' ,
54- 'handleMore'
54+ 'handleMore' ,
55+ 'handleBackpackRefresh'
5556 ] ) ;
5657 this . state = {
5758 // While the DroppableHOC manages drop interactions for asset tiles,
@@ -85,6 +86,7 @@ class Backpack extends React.Component {
8586 document . addEventListener ( 'keydown' , this . handleGlobalKeyDown ) ;
8687 window . addEventListener ( 'resize' , this . handleCloseContextMenu ) ;
8788 window . addEventListener ( 'scroll' , this . handleCloseContextMenu , true ) ;
89+ window . addEventListener ( 'backpack-refresh' , this . handleBackpackRefresh ) ;
8890 }
8991 componentWillUnmount ( ) {
9092 this . props . vm . removeListener ( 'BLOCK_DRAG_END' , this . handleBlockDragEnd ) ;
@@ -93,6 +95,7 @@ class Backpack extends React.Component {
9395 document . removeEventListener ( 'keydown' , this . handleGlobalKeyDown ) ;
9496 window . removeEventListener ( 'resize' , this . handleCloseContextMenu ) ;
9597 window . removeEventListener ( 'scroll' , this . handleCloseContextMenu , true ) ;
98+ window . removeEventListener ( 'backpack-refresh' , this . handleBackpackRefresh ) ;
9699 }
97100 getBackpackAssetURL ( asset ) {
98101 return `${ this . props . host } /${ asset . assetId } .${ asset . dataFormat } ` ;
@@ -305,6 +308,15 @@ class Backpack extends React.Component {
305308 this . handleCloseContextMenu ( ) ;
306309 }
307310 }
311+ handleBackpackRefresh ( ) {
312+ // 当调试窗口写入数据后,刷新书包内容
313+ if ( this . state . expanded ) {
314+ this . setState ( { contents : [ ] } , ( ) => {
315+ this . getContents ( ) ;
316+ } ) ;
317+ }
318+ }
319+
308320 setContextMenuRef ( ref ) {
309321 this . contextMenuRef = ref ;
310322 }
0 commit comments