Compare commits
2 Commits
2dccc36d32
...
1bf75d3611
| Author | SHA1 | Date | |
|---|---|---|---|
| 1bf75d3611 | |||
| 67aef1df33 |
8
components.d.ts
vendored
8
components.d.ts
vendored
@ -7,19 +7,11 @@ export {}
|
|||||||
/* prettier-ignore */
|
/* prettier-ignore */
|
||||||
declare module 'vue' {
|
declare module 'vue' {
|
||||||
export interface GlobalComponents {
|
export interface GlobalComponents {
|
||||||
AButton: typeof import('@arco-design/web-vue')['Button']
|
|
||||||
AInput: typeof import('@arco-design/web-vue')['Input']
|
|
||||||
ARate: typeof import('@arco-design/web-vue')['Rate']
|
|
||||||
AScrollbar: typeof import('@arco-design/web-vue')['Scrollbar']
|
|
||||||
ASwitch: typeof import('@arco-design/web-vue')['Switch']
|
|
||||||
ATable: typeof import('@arco-design/web-vue')['Table']
|
|
||||||
DynamicComponent: typeof import('./src/components/DynamicComponent.vue')['default']
|
DynamicComponent: typeof import('./src/components/DynamicComponent.vue')['default']
|
||||||
ElTable: typeof import('./src/components/ElTable.vue')['default']
|
ElTable: typeof import('./src/components/ElTable.vue')['default']
|
||||||
FunctionalIcons: typeof import('./src/components/FunctionalIcons.vue')['default']
|
|
||||||
NestedDirective: typeof import('./src/components/NestedDirective.vue')['default']
|
NestedDirective: typeof import('./src/components/NestedDirective.vue')['default']
|
||||||
NestedFunction: typeof import('./src/components/NestedFunction.vue')['default']
|
NestedFunction: typeof import('./src/components/NestedFunction.vue')['default']
|
||||||
TestComponent: typeof import('./src/components/TestComponent.vue')['default']
|
TestComponent: typeof import('./src/components/TestComponent.vue')['default']
|
||||||
TestParentComponent: typeof import('./src/components/TestParentComponent.vue')['default']
|
|
||||||
VueDemo: typeof import('./src/components/VueDemo.vue')['default']
|
VueDemo: typeof import('./src/components/VueDemo.vue')['default']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
19
package-lock.json
generated
19
package-lock.json
generated
@ -10,6 +10,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@arco-plugins/vite-vue": "^1.4.5",
|
"@arco-plugins/vite-vue": "^1.4.5",
|
||||||
"@vueuse/core": "^10.11.0",
|
"@vueuse/core": "^10.11.0",
|
||||||
|
"js-yaml": "^4.1.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"lsp-uuid": "^3.2.0",
|
"lsp-uuid": "^3.2.0",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
@ -1600,6 +1601,12 @@
|
|||||||
"resolved": "https://registry.npmmirror.com/arg/-/arg-4.1.3.tgz",
|
"resolved": "https://registry.npmmirror.com/arg/-/arg-4.1.3.tgz",
|
||||||
"integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA=="
|
"integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA=="
|
||||||
},
|
},
|
||||||
|
"node_modules/argparse": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://repo.bingosoft.net/repository/npm/argparse/-/argparse-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
|
||||||
|
"license": "Python-2.0"
|
||||||
|
},
|
||||||
"node_modules/b-tween": {
|
"node_modules/b-tween": {
|
||||||
"version": "0.3.3",
|
"version": "0.3.3",
|
||||||
"resolved": "https://registry.npmmirror.com/b-tween/-/b-tween-0.3.3.tgz",
|
"resolved": "https://registry.npmmirror.com/b-tween/-/b-tween-0.3.3.tgz",
|
||||||
@ -2296,6 +2303,18 @@
|
|||||||
"integrity": "sha512-WriZw1luRMlmV3LGJaR6QOJjWwgLUTf89OwT2lUOyjX2dJGBwgmIkbcz+7WFZjrZM635JOIR517++e/67CP9dQ==",
|
"integrity": "sha512-WriZw1luRMlmV3LGJaR6QOJjWwgLUTf89OwT2lUOyjX2dJGBwgmIkbcz+7WFZjrZM635JOIR517++e/67CP9dQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"node_modules/js-yaml": {
|
||||||
|
"version": "4.1.0",
|
||||||
|
"resolved": "https://repo.bingosoft.net/repository/npm/js-yaml/-/js-yaml-4.1.0.tgz",
|
||||||
|
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"argparse": "^2.0.1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"js-yaml": "bin/js-yaml.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/jsesc": {
|
"node_modules/jsesc": {
|
||||||
"version": "2.5.2",
|
"version": "2.5.2",
|
||||||
"resolved": "https://registry.npmmirror.com/jsesc/-/jsesc-2.5.2.tgz",
|
"resolved": "https://registry.npmmirror.com/jsesc/-/jsesc-2.5.2.tgz",
|
||||||
|
|||||||
@ -12,6 +12,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@arco-plugins/vite-vue": "^1.4.5",
|
"@arco-plugins/vite-vue": "^1.4.5",
|
||||||
"@vueuse/core": "^10.11.0",
|
"@vueuse/core": "^10.11.0",
|
||||||
|
"js-yaml": "^4.1.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"lsp-uuid": "^3.2.0",
|
"lsp-uuid": "^3.2.0",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
|
|||||||
@ -5,6 +5,11 @@
|
|||||||
<template v-for="child in componentChildren" :key="child.id">
|
<template v-for="child in componentChildren" :key="child.id">
|
||||||
<DynamicComponent :component-data="child" />
|
<DynamicComponent :component-data="child" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template v-for="(slot,key, index) in componentSlots" :key="index" v-slot:[key]>
|
||||||
|
<DynamicComponent :component-data="slot" />
|
||||||
|
</template>
|
||||||
|
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
@ -23,9 +28,11 @@ onMounted(() => {
|
|||||||
const componentType = computed(() => componentMapping[props.componentData?.type] || 'div');
|
const componentType = computed(() => componentMapping[props.componentData?.type] || 'div');
|
||||||
const componentProps = computed(() => props.componentData?.props || {});
|
const componentProps = computed(() => props.componentData?.props || {});
|
||||||
const componentChildren = computed(() => props.componentData?.children || []);
|
const componentChildren = computed(() => props.componentData?.children || []);
|
||||||
const componentText = computed(() => props.componentData?.text ||'');
|
const componentText = computed(() => props.componentData?.text || '');
|
||||||
const componentClass = computed(() => props.componentData?.class || []);
|
const componentClass = computed(() => props.componentData?.class || []);
|
||||||
const componentStyle = computed(() => props.componentData?.style || []);
|
const componentStyle = computed(() => props.componentData?.style || []);
|
||||||
|
const componentSlots = computed(() => props.componentData?.slots || []);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@ -1,18 +1,29 @@
|
|||||||
|
<!-- DynamicSlotsComponent.vue -->
|
||||||
<template>
|
<template>
|
||||||
<div class="my-component">
|
<div>
|
||||||
<slot name="header"></slot>
|
<!-- 动态插槽 -->
|
||||||
<slot name="extra"></slot>
|
|
||||||
|
<div>
|
||||||
|
<slot name="header"></slot>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<slot name="main"></slot>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<slot name="footer"></slot>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
export default {
|
import { defineProps } from 'vue';
|
||||||
name: 'MyComponent',
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
// 接收一个动态插槽名作为 prop
|
||||||
.my-component {
|
const props = defineProps({
|
||||||
/* 添加样式 */
|
dynamicSlotName: String
|
||||||
}
|
});
|
||||||
</style>
|
</script>
|
||||||
@ -1,5 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div style="display: flex;flex-direction: row;">
|
<div style="display: flex;flex-direction: row;">
|
||||||
|
|
||||||
<div ref="el2"
|
<div ref="el2"
|
||||||
@ -24,14 +28,20 @@
|
|||||||
{{ component.id }}
|
{{ component.id }}
|
||||||
</DynamicComponent>
|
</DynamicComponent>
|
||||||
</div>
|
</div>
|
||||||
<TestComponent>
|
<div>
|
||||||
<template #header>
|
|
||||||
<div>
|
<TestComponent >
|
||||||
header
|
<!-- 默认插槽内容 -->
|
||||||
</div>
|
<template #default>
|
||||||
|
Default slot content.
|
||||||
|
</template>
|
||||||
|
<!-- 动态插槽内容 -->
|
||||||
|
<template v-for="(slot, index) in dynamicSlotContents" :key="index" v-slot:[slot.slotName]>
|
||||||
|
{{ slot.content }}
|
||||||
</template>
|
</template>
|
||||||
</TestComponent>
|
</TestComponent>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
@ -41,16 +51,25 @@ import { onMounted, ref } from 'vue';
|
|||||||
import NestedFunction from './NestedFunction.vue';
|
import NestedFunction from './NestedFunction.vue';
|
||||||
import DynamicComponent from './DynamicComponent.vue';
|
import DynamicComponent from './DynamicComponent.vue';
|
||||||
|
|
||||||
import { useDraggable } from 'vue-draggable-plus'
|
import { useDraggable } from 'vue-draggable-plus';
|
||||||
import { uuid } from 'lsp-uuid';
|
import { uuid } from 'lsp-uuid';
|
||||||
import { IComponent } from '../type/IComponent.ts';
|
import { IComponent } from '../type/IComponent.ts';
|
||||||
import { componentScheme } from '../schemes/scheme.ts';
|
import { componentScheme } from '../schemes/scheme.ts';
|
||||||
import TestComponent from './TestComponent.vue';
|
import TestComponent from './TestComponent.vue';
|
||||||
|
|
||||||
|
const dynamicSlotContents = ref([
|
||||||
|
{ slotName: 'header', content: 'Header content' },
|
||||||
|
{ slotName: 'footer', content: 'Footer content' },
|
||||||
|
{ slotName: 'main', content: 'Main content' }
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
const componentsList = ref<any[]>([]);
|
const componentsList = ref<any[]>([]);
|
||||||
|
|
||||||
const list = ref<IComponent[]>([])
|
|
||||||
|
|
||||||
const el2 = ref()
|
const list = ref<IComponent[]>([]);
|
||||||
|
|
||||||
|
const el2 = ref();
|
||||||
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@ -69,7 +88,7 @@ useDraggable(el2, componentsList, {
|
|||||||
onClone() {
|
onClone() {
|
||||||
console.log('clone')
|
console.log('clone')
|
||||||
},
|
},
|
||||||
clone(element: Record<'id' | 'name' | 'type' | 'children' | 'props' | 'text' | 'class' | 'style', any>) {
|
clone(element: Record<'id' | 'name' | 'type' | 'children' | 'props' | 'text' | 'class' | 'style'|'slots', any>) {
|
||||||
return {
|
return {
|
||||||
id: `${element.id}-${uuid()}`,
|
id: `${element.id}-${uuid()}`,
|
||||||
name: element.name,
|
name: element.name,
|
||||||
@ -81,7 +100,7 @@ useDraggable(el2, componentsList, {
|
|||||||
children: [],
|
children: [],
|
||||||
style: element.style,
|
style: element.style,
|
||||||
visible: "",
|
visible: "",
|
||||||
slots: {},
|
slots: element.slots,
|
||||||
disable: "",
|
disable: "",
|
||||||
events: {},
|
events: {},
|
||||||
loop: {},
|
loop: {},
|
||||||
|
|||||||
@ -4,15 +4,32 @@
|
|||||||
"id": "card",
|
"id": "card",
|
||||||
"designer": {},
|
"designer": {},
|
||||||
"text": "ByteDance's core product, Toutiao (\"Headlines\"), is a content platform in China and around the world. Toutiao started out as a news recommendation engine and gradually evolved into a platform delivering content in various formats.",
|
"text": "ByteDance's core product, Toutiao (\"Headlines\"), is a content platform in China and around the world. Toutiao started out as a news recommendation engine and gradually evolved into a platform delivering content in various formats.",
|
||||||
"props": {"title":"Card"},
|
"props": {
|
||||||
|
"title": "Card"
|
||||||
|
},
|
||||||
"style": "width:360px",
|
"style": "width:360px",
|
||||||
"class": "arco-card arco-card-size-medium arco-card-bordered",
|
"class": "arco-card arco-card-size-medium arco-card-bordered",
|
||||||
"visible": "",
|
"visible": "",
|
||||||
"slots": {},
|
"slots": {
|
||||||
|
"extra":{
|
||||||
|
"id": "avatar-9f8289a12910000",
|
||||||
|
"name": "avatar",
|
||||||
|
"type": "Avatar",
|
||||||
|
"props": {},
|
||||||
|
"class": "",
|
||||||
|
"designer": "",
|
||||||
|
"text": "",
|
||||||
|
"children": [],
|
||||||
|
"style": "",
|
||||||
|
"visible": "",
|
||||||
|
"slots": {},
|
||||||
|
"disable": "",
|
||||||
|
"events": {},
|
||||||
|
"loop": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
"disable": "",
|
"disable": "",
|
||||||
"events": {},
|
"events": {},
|
||||||
"loop": {},
|
"loop": {},
|
||||||
"children": []
|
"children": []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -238,7 +238,24 @@
|
|||||||
"style": "width:360px",
|
"style": "width:360px",
|
||||||
"class": "arco-card arco-card-size-medium arco-card-bordered",
|
"class": "arco-card arco-card-size-medium arco-card-bordered",
|
||||||
"visible": "",
|
"visible": "",
|
||||||
"slots": {},
|
"slots": {
|
||||||
|
"extra": {
|
||||||
|
"id": "avatar-9f8289a12910000",
|
||||||
|
"name": "avatar",
|
||||||
|
"type": "Avatar",
|
||||||
|
"props": {},
|
||||||
|
"class": "",
|
||||||
|
"designer": "",
|
||||||
|
"text": "",
|
||||||
|
"children": [],
|
||||||
|
"style": "",
|
||||||
|
"visible": "",
|
||||||
|
"slots": {},
|
||||||
|
"disable": "",
|
||||||
|
"events": {},
|
||||||
|
"loop": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
"disable": "",
|
"disable": "",
|
||||||
"events": {},
|
"events": {},
|
||||||
"loop": {},
|
"loop": {},
|
||||||
|
|||||||
@ -238,7 +238,24 @@ export const componentScheme = {
|
|||||||
"style": "width:360px",
|
"style": "width:360px",
|
||||||
"class": "arco-card arco-card-size-medium arco-card-bordered",
|
"class": "arco-card arco-card-size-medium arco-card-bordered",
|
||||||
"visible": "",
|
"visible": "",
|
||||||
"slots": {},
|
"slots": {
|
||||||
|
"extra": {
|
||||||
|
"id": "avatar-9f8289a12910000",
|
||||||
|
"name": "avatar",
|
||||||
|
"type": "Avatar",
|
||||||
|
"props": {},
|
||||||
|
"class": "",
|
||||||
|
"designer": "",
|
||||||
|
"text": "",
|
||||||
|
"children": [],
|
||||||
|
"style": "",
|
||||||
|
"visible": "",
|
||||||
|
"slots": {},
|
||||||
|
"disable": "",
|
||||||
|
"events": {},
|
||||||
|
"loop": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
"disable": "",
|
"disable": "",
|
||||||
"events": {},
|
"events": {},
|
||||||
"loop": {},
|
"loop": {},
|
||||||
|
|||||||
Reference in New Issue
Block a user