-
Notifications
You must be signed in to change notification settings - Fork 677
/
AddPageBox.vue
36 lines (29 loc) · 897 Bytes
/
AddPageBox.vue
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
<template>
<div class="m-editor-empty-panel">
<div class="m-editor-empty-content">
<div class="m-editor-empty-button" @click="clickHandler">
<div>
<MIcon :icon="Plus"></MIcon>
</div>
<p>新增页面</p>
</div>
</div>
</div>
</template>
<script lang="ts" setup name="MEditorAddPageBox">
import { inject, toRaw } from 'vue';
import { Plus } from '@element-plus/icons-vue';
import { NodeType } from '@tmagic/schema';
import MIcon from '../components/Icon.vue';
import type { Services } from '../type';
import { generatePageNameByApp } from '../utils';
const services = inject<Services>('services');
const clickHandler = () => {
const { editorService } = services || {};
if (!editorService) return;
editorService.add({
type: NodeType.PAGE,
name: generatePageNameByApp(toRaw(editorService.get('root'))),
});
};
</script>