update
This commit is contained in:
		| @@ -2,4 +2,44 @@ | ||||
| title: 右键菜单 | ||||
| sTitle: dooringx-lib插件开发 | ||||
| order: 15 | ||||
| --- | ||||
| --- | ||||
|  | ||||
| 右键菜单可以进行自定义: | ||||
|  | ||||
| ```js | ||||
| // 自定义右键 | ||||
| const contextMenuState = config.getContextMenuState(); | ||||
| const unmountContextMenu = contextMenuState.unmountContextMenu; | ||||
| const commander = config.getCommanderRegister(); | ||||
| const ContextMenu = () => { | ||||
| 	const handleclick = () => { | ||||
| 		unmountContextMenu(); | ||||
| 	}; | ||||
| 	return ( | ||||
| 		<div | ||||
| 			style={{ | ||||
| 				left: contextMenuState.left, | ||||
| 				top: contextMenuState.top, | ||||
| 				position: 'fixed', | ||||
| 				background: 'rgb(24, 23, 23)', | ||||
| 			}} | ||||
| 		> | ||||
| 			<div | ||||
| 				style={{ width: '100%' }} | ||||
| 				onClick={() => { | ||||
| 					commander.exec('redo'); | ||||
| 					handleclick(); | ||||
| 				}} | ||||
| 			> | ||||
| 				<Button>自定义</Button> | ||||
| 			</div> | ||||
| 		</div> | ||||
| 	); | ||||
| }; | ||||
| contextMenuState.contextMenu = <ContextMenu></ContextMenu>; | ||||
| ``` | ||||
| 先拿到contextMenuState,contextMenuState上有个unmountContextMenu是关闭右键菜单方法。 | ||||
|  | ||||
| 所以在点击后需要调用关闭。 | ||||
|  | ||||
| 同时上面的left和top是右键的位置。 | ||||
		Reference in New Issue
	
	Block a user
	 yehuozhili
					yehuozhili