fix: lock component
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* @Author: yehuozhili
|
||||
* @Date: 2021-07-07 14:51:17
|
||||
* @LastEditors: yehuozhili
|
||||
* @LastEditTime: 2021-07-13 19:55:15
|
||||
* @LastEditTime: 2021-07-27 16:24:29
|
||||
* @FilePath: \dooringx\packages\dooringx-example\src\layouts\index.tsx
|
||||
*/
|
||||
import { Button } from 'antd';
|
||||
@@ -47,6 +47,24 @@ const ContextMenu = () => {
|
||||
>
|
||||
<Button>自定义</Button>
|
||||
</div>
|
||||
<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>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
27
packages/dooringx-example/src/plugin/commands/lock.ts
Normal file
27
packages/dooringx-example/src/plugin/commands/lock.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* @Author: yehuozhili
|
||||
* @Date: 2021-07-27 16:19:58
|
||||
* @LastEditors: yehuozhili
|
||||
* @LastEditTime: 2021-07-27 16:19:59
|
||||
* @FilePath: \dooringx\packages\dooringx-example\src\plugin\commands\lock.ts
|
||||
*/
|
||||
import deepcopy from 'deepcopy';
|
||||
import { CommanderItemFactory } from 'dooringx-lib';
|
||||
import { IStoreData } from 'dooringx-lib/dist/core/store/storetype';
|
||||
|
||||
const lock = new CommanderItemFactory(
|
||||
'lock',
|
||||
'',
|
||||
(store) => {
|
||||
const clonedata: IStoreData = deepcopy(store.getData());
|
||||
clonedata.block.forEach((v) => {
|
||||
if (v.focus) {
|
||||
v.canDrag = false;
|
||||
}
|
||||
});
|
||||
store.setData(clonedata);
|
||||
},
|
||||
'锁定'
|
||||
);
|
||||
|
||||
export default lock;
|
27
packages/dooringx-example/src/plugin/commands/unlock.ts
Normal file
27
packages/dooringx-example/src/plugin/commands/unlock.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* @Author: yehuozhili
|
||||
* @Date: 2021-07-27 16:20:04
|
||||
* @LastEditors: yehuozhili
|
||||
* @LastEditTime: 2021-07-27 16:20:20
|
||||
* @FilePath: \dooringx\packages\dooringx-example\src\plugin\commands\unlock.ts
|
||||
*/
|
||||
import deepcopy from 'deepcopy';
|
||||
import { CommanderItemFactory } from 'dooringx-lib';
|
||||
import { IStoreData } from 'dooringx-lib/dist/core/store/storetype';
|
||||
|
||||
const unlock = new CommanderItemFactory(
|
||||
'unlock',
|
||||
'',
|
||||
(store) => {
|
||||
const clonedata: IStoreData = deepcopy(store.getData());
|
||||
clonedata.block.forEach((v) => {
|
||||
if (v.focus) {
|
||||
v.canDrag = true;
|
||||
}
|
||||
});
|
||||
store.setData(clonedata);
|
||||
},
|
||||
'解锁'
|
||||
);
|
||||
|
||||
export default unlock;
|
Reference in New Issue
Block a user