-
Notifications
You must be signed in to change notification settings - Fork 707
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
roymondchen
committed
Dec 19, 2023
1 parent
698c345
commit 7b6dced
Showing
58 changed files
with
1,416 additions
and
235 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<template> | ||
<div class="m-fields-page-fragment-select"> | ||
<div class="page-fragment-select-container"> | ||
<!-- 页面片下拉框 --> | ||
<m-form-container | ||
class="select" | ||
:config="selectConfig" | ||
:model="model" | ||
:size="size" | ||
@change="changeHandler" | ||
></m-form-container> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { computed, inject } from 'vue'; | ||
import { FieldProps } from '@tmagic/form'; | ||
import { NodeType } from '@tmagic/schema'; | ||
import type { PageFragmentSelectConfig, Services } from '@editor/type'; | ||
defineOptions({ | ||
name: 'MEditorPageFragmentSelect', | ||
}); | ||
const services = inject<Services>('services'); | ||
const emit = defineEmits(['change']); | ||
const props = withDefaults(defineProps<FieldProps<PageFragmentSelectConfig>>(), { | ||
disabled: false, | ||
}); | ||
const pageList = computed(() => | ||
services?.editorService.get('root')?.items.filter((item) => item.type === NodeType.PAGE_FRAGMENT), | ||
); | ||
const selectConfig = { | ||
type: 'select', | ||
name: props.name, | ||
options: () => { | ||
if (pageList.value) { | ||
return pageList.value.map((item) => ({ | ||
text: `${item.name}(${item.id})`, | ||
label: `${item.name}(${item.id})`, | ||
value: item.id, | ||
})); | ||
} | ||
return []; | ||
}, | ||
}; | ||
const changeHandler = async () => { | ||
emit('change', props.model[props.name]); | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<template> | ||
<div | ||
v-if="showAddPageButton" | ||
id="m-editor-page-bar-add-icon" | ||
class="m-editor-page-bar-item m-editor-page-bar-item-icon" | ||
@click="addPage" | ||
> | ||
<Icon :icon="Plus"></Icon> | ||
</div> | ||
<div v-else style="width: 21px"></div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { computed, inject, toRaw } from 'vue'; | ||
import { Plus } from '@element-plus/icons-vue'; | ||
import { NodeType } from '@tmagic/schema'; | ||
import Icon from '@editor/components/Icon.vue'; | ||
import type { Services } from '@editor/type'; | ||
import { generatePageNameByApp } from '@editor/utils/editor'; | ||
defineOptions({ | ||
name: 'MEditorPageBarAddButton', | ||
}); | ||
const props = defineProps<{ | ||
type: NodeType.PAGE | NodeType.PAGE_FRAGMENT; | ||
}>(); | ||
const services = inject<Services>('services'); | ||
const uiService = services?.uiService; | ||
const editorService = services?.editorService; | ||
const showAddPageButton = computed(() => uiService?.get('showAddPageButton')); | ||
const addPage = () => { | ||
if (!editorService) return; | ||
const root = toRaw(editorService.get('root')); | ||
if (!root) throw new Error('root 不能为空'); | ||
const pageConfig = { | ||
type: props.type, | ||
name: generatePageNameByApp(root, props.type), | ||
items: [], | ||
}; | ||
editorService.add(pageConfig); | ||
}; | ||
</script> |
Oops, something went wrong.