Files
dooring/packages/dooringx-example/src/layouts/index.tsx

76 lines
1.9 KiB
TypeScript
Raw Normal View History

2021-07-10 19:35:06 +08:00
/*
* @Author: yehuozhili
* @Date: 2021-07-07 14:51:17
* @LastEditors: yehuozhili
2021-07-27 16:35:09 +08:00
* @LastEditTime: 2021-07-27 16:24:29
2021-07-10 19:35:06 +08:00
* @FilePath: \dooringx\packages\dooringx-example\src\layouts\index.tsx
*/
import { Button } from 'antd';
2021-07-13 20:15:38 +08:00
import { UserConfig } from 'dooringx-lib';
2021-07-10 19:35:06 +08:00
import 'dooringx-lib/dist/dooringx-lib.esm.css';
2021-07-13 20:15:38 +08:00
import { createContext, useState } from 'react';
2021-07-10 19:35:06 +08:00
import { IRouteComponentProps } from 'umi';
import plugin from '../plugin';
import 'antd/dist/antd.css';
import '../global.less';
import 'animate.css';
export const config = new UserConfig(plugin);
export const configContext = createContext<UserConfig>(config);
// 自定义右键
const contextMenuState = config.getContextMenuState();
const unmountContextMenu = contextMenuState.unmountContextMenu;
const commander = config.getCommanderRegister();
const ContextMenu = () => {
const handleclick = () => {
unmountContextMenu();
};
2021-07-13 20:15:38 +08:00
const forceUpdate = useState(0)[1];
contextMenuState.forceUpdate = () => {
forceUpdate((pre) => pre + 1);
};
2021-07-10 19:35:06 +08:00
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>
2021-07-27 16:35:09 +08:00
<div
style={{ width: '100%' }}
onClick={() => {
commander.exec('lock');
handleclick();
}}
>
<Button style={{ width: '100%' }}></Button>
</div>
<div
style={{ width: '100%' }}
onClick={() => {
commander.exec('unlock');
handleclick();
}}
>
<Button style={{ width: '100%' }}></Button>
</div>
2021-07-10 19:35:06 +08:00
</div>
);
};
contextMenuState.contextMenu = <ContextMenu></ContextMenu>;
export default function Layout({ children }: IRouteComponentProps) {
return <configContext.Provider value={config}>{children}</configContext.Provider>;
}