@@ -25,7 +25,7 @@ import {
25
25
} from "lowcoder-design" ;
26
26
import { trans } from "i18n" ;
27
27
import dayjs from "dayjs" ;
28
- import { useContext , useState } from "react" ;
28
+ import { useContext , useEffect , useMemo , useState } from "react" ;
29
29
import { useDispatch , useSelector } from "react-redux" ;
30
30
import {
31
31
publishApplication ,
@@ -453,67 +453,74 @@ export default function Header(props: HeaderProps) {
453
453
</ >
454
454
) ;
455
455
456
- const headerEnd = showAppSnapshot ? (
457
- < HeaderProfile user = { user } />
458
- ) : (
459
- < >
460
- { applicationId && (
461
- < AppPermissionDialog
462
- applicationId = { applicationId }
463
- visible = { permissionDialogVisible }
464
- onVisibleChange = { ( visible ) =>
465
- ! visible && setPermissionDialogVisible ( false )
466
- }
467
- />
468
- ) }
469
- { canManageApp ( user , application ) && (
470
- < GrayBtn onClick = { ( ) => setPermissionDialogVisible ( true ) } >
471
- { SHARE_TITLE }
472
- </ GrayBtn >
473
- ) }
474
- < PreviewBtn buttonType = "primary" onClick = { ( ) => preview ( applicationId ) } >
475
- { trans ( "header.preview" ) }
476
- </ PreviewBtn >
477
-
478
- < Dropdown
479
- className = "cypress-header-dropdown"
480
- placement = "bottomRight"
481
- trigger = { [ "click" ] }
482
- dropdownRender = { ( ) => (
483
- < DropdownMenuStyled
484
- style = { { minWidth : "110px" , borderRadius : "4px" } }
485
- onClick = { ( e ) => {
486
- if ( e . key === "deploy" ) {
487
- dispatch ( publishApplication ( { applicationId } ) ) ;
488
- } else if ( e . key === "snapshot" ) {
489
- dispatch ( setShowAppSnapshot ( true ) ) ;
490
- }
491
- } }
492
- items = { [
493
- {
494
- key : "deploy" ,
495
- label : (
496
- < CommonTextLabel > { trans ( "header.deploy" ) } </ CommonTextLabel >
497
- ) ,
498
- } ,
499
- {
500
- key : "snapshot" ,
501
- label : (
502
- < CommonTextLabel > { trans ( "header.snapshot" ) } </ CommonTextLabel >
503
- ) ,
504
- } ,
505
- ] }
456
+ const headerEnd = useMemo ( ( ) => {
457
+ return showAppSnapshot ? (
458
+ < HeaderProfile user = { user } />
459
+ ) : (
460
+ < >
461
+ { applicationId && (
462
+ < AppPermissionDialog
463
+ applicationId = { applicationId }
464
+ visible = { permissionDialogVisible }
465
+ onVisibleChange = { ( visible ) =>
466
+ ! visible && setPermissionDialogVisible ( false )
467
+ }
506
468
/>
507
469
) }
508
- >
509
- < PackUpBtn buttonType = "primary" >
510
- < PackUpIcon />
511
- </ PackUpBtn >
512
- </ Dropdown >
470
+ { canManageApp ( user , application ) && (
471
+ < GrayBtn onClick = { ( ) => setPermissionDialogVisible ( true ) } >
472
+ { SHARE_TITLE }
473
+ </ GrayBtn >
474
+ ) }
475
+ < PreviewBtn buttonType = "primary" onClick = { ( ) => preview ( applicationId ) } >
476
+ { trans ( "header.preview" ) }
477
+ </ PreviewBtn >
478
+
479
+ < Dropdown
480
+ className = "cypress-header-dropdown"
481
+ placement = "bottomRight"
482
+ trigger = { [ "click" ] }
483
+ dropdownRender = { ( ) => (
484
+ < DropdownMenuStyled
485
+ style = { { minWidth : "110px" , borderRadius : "4px" } }
486
+ onClick = { ( e ) => {
487
+ if ( e . key === "deploy" ) {
488
+ dispatch ( publishApplication ( { applicationId } ) ) ;
489
+ } else if ( e . key === "snapshot" ) {
490
+ dispatch ( setShowAppSnapshot ( true ) ) ;
491
+ }
492
+ } }
493
+ items = { [
494
+ {
495
+ key : "deploy" ,
496
+ label : (
497
+ < CommonTextLabel > { trans ( "header.deploy" ) } </ CommonTextLabel >
498
+ ) ,
499
+ } ,
500
+ {
501
+ key : "snapshot" ,
502
+ label : (
503
+ < CommonTextLabel > { trans ( "header.snapshot" ) } </ CommonTextLabel >
504
+ ) ,
505
+ } ,
506
+ ] }
507
+ />
508
+ ) }
509
+ >
510
+ < PackUpBtn buttonType = "primary" >
511
+ < PackUpIcon />
512
+ </ PackUpBtn >
513
+ </ Dropdown >
513
514
514
- < HeaderProfile user = { user } />
515
- </ >
516
- ) ;
515
+ < HeaderProfile user = { user } />
516
+ </ >
517
+ ) ;
518
+ } , [
519
+ user ,
520
+ showAppSnapshot ,
521
+ applicationId ,
522
+ permissionDialogVisible ,
523
+ ] ) ;
517
524
518
525
return (
519
526
< LayoutHeader
0 commit comments