mirror of
				https://github.com/Tencent/tmagic-editor.git
				synced 2025-11-04 02:28:04 +08:00 
			
		
		
		
	feat(editor): 增加FloatBox的beforeClose函数
This commit is contained in:
		
							parent
							
								
									cae928f7f9
								
							
						
					
					
						commit
						7ce60b223e
					
				@ -33,12 +33,21 @@ interface Rect {
 | 
				
			|||||||
  height: number | string;
 | 
					  height: number | string;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const props = withDefaults(defineProps<{ visible: boolean; position?: Position; rect?: Rect; title?: string }>(), {
 | 
					const props = withDefaults(
 | 
				
			||||||
  visible: false,
 | 
					  defineProps<{
 | 
				
			||||||
  title: '',
 | 
					    visible: boolean;
 | 
				
			||||||
  position: () => ({ left: 0, top: 0 }),
 | 
					    position?: Position;
 | 
				
			||||||
  rect: () => ({ width: 'auto', height: 'auto' }),
 | 
					    rect?: Rect;
 | 
				
			||||||
});
 | 
					    title?: string;
 | 
				
			||||||
 | 
					    beforeClose?: (done: (cancel?: boolean) => void) => void;
 | 
				
			||||||
 | 
					  }>(),
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    visible: false,
 | 
				
			||||||
 | 
					    title: '',
 | 
				
			||||||
 | 
					    position: () => ({ left: 0, top: 0 }),
 | 
				
			||||||
 | 
					    rect: () => ({ width: 'auto', height: 'auto' }),
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const emit = defineEmits<{
 | 
					const emit = defineEmits<{
 | 
				
			||||||
  'update:visible': [boolean];
 | 
					  'update:visible': [boolean];
 | 
				
			||||||
@ -125,8 +134,18 @@ onBeforeUnmount(() => {
 | 
				
			|||||||
  destroyMoveable();
 | 
					  destroyMoveable();
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const hide = (cancel?: boolean) => {
 | 
				
			||||||
 | 
					  if (cancel !== false) {
 | 
				
			||||||
 | 
					    emit('update:visible', false);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const closeHandler = () => {
 | 
					const closeHandler = () => {
 | 
				
			||||||
  emit('update:visible', false);
 | 
					  if (typeof props.beforeClose === 'function') {
 | 
				
			||||||
 | 
					    props.beforeClose(hide);
 | 
				
			||||||
 | 
					  } else {
 | 
				
			||||||
 | 
					    hide();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const nextZIndex = () => {
 | 
					const nextZIndex = () => {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user