@@ -25,7 +25,7 @@ import {
2525} from "lowcoder-design" ;
2626import { trans } from "i18n" ;
2727import dayjs from "dayjs" ;
28- import { useContext , useState } from "react" ;
28+ import { useContext , useEffect , useMemo , useState } from "react" ;
2929import { useDispatch , useSelector } from "react-redux" ;
3030import {
3131 publishApplication ,
@@ -453,67 +453,74 @@ export default function Header(props: HeaderProps) {
453453 </ >
454454 ) ;
455455
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+ }
506468 />
507469 ) }
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 >
513514
514- < HeaderProfile user = { user } />
515- </ >
516- ) ;
515+ < HeaderProfile user = { user } />
516+ </ >
517+ ) ;
518+ } , [
519+ user ,
520+ showAppSnapshot ,
521+ applicationId ,
522+ permissionDialogVisible ,
523+ ] ) ;
517524
518525 return (
519526 < LayoutHeader
0 commit comments