forked from KNXCloud/lowcode-engine-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactions.tsx
More file actions
51 lines (43 loc) · 1.12 KB
/
Copy pathactions.tsx
File metadata and controls
51 lines (43 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { Button, Message } from '@alifd/next';
import { saveSchema } from '@/utils/store';
import { ILowCodePluginContext } from '@alilc/lowcode-engine';
const save = async () => {
await saveSchema();
Message.success('成功保存到本地');
};
const preview = async () => {
await saveSchema();
window.open('preview.html');
};
const savePlugin = (ctx: ILowCodePluginContext) => {
return {
name: 'saveSample',
async init() {
const { skeleton, hotkey } = ctx;
skeleton.add({
name: 'saveSample',
area: 'topArea',
type: 'Widget',
props: { align: 'right' },
content: <Button onClick={save}>保存到本地</Button>,
});
skeleton.add({
name: 'previewSample',
area: 'topArea',
type: 'Widget',
props: { align: 'right' },
content: (
<Button type="primary" onClick={preview}>
预览
</Button>
),
});
hotkey.bind('command+s', async (e) => {
e.preventDefault();
save();
});
},
};
};
savePlugin.pluginName = 'saveSample';
export default savePlugin;