Compare commits
2 Commits
f25b03fff5
...
5f1825c164
| Author | SHA1 | Date | |
|---|---|---|---|
| 5f1825c164 | |||
| f411974bd3 |
1
components.d.ts
vendored
1
components.d.ts
vendored
@ -8,6 +8,7 @@ export {}
|
|||||||
declare module 'vue' {
|
declare module 'vue' {
|
||||||
export interface GlobalComponents {
|
export interface GlobalComponents {
|
||||||
AdaptivePage: typeof import('./src/components/AdaptivePage.vue')['default']
|
AdaptivePage: typeof import('./src/components/AdaptivePage.vue')['default']
|
||||||
|
ComponentHeader: typeof import('./src/components/DynamicComponent/ComponentHeader.vue')['default']
|
||||||
DynamicComponent: typeof import('./src/components/DynamicComponent.vue')['default']
|
DynamicComponent: typeof import('./src/components/DynamicComponent.vue')['default']
|
||||||
NestedFunction: typeof import('./src/components/NestedFunction.vue')['default']
|
NestedFunction: typeof import('./src/components/NestedFunction.vue')['default']
|
||||||
PropertyEditor: typeof import('./src/components/PropertyEditor.vue')['default']
|
PropertyEditor: typeof import('./src/components/PropertyEditor.vue')['default']
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<div :style="headerStyle">
|
<div style="height:100%;width:100%;">
|
||||||
<div style="width: 100%;">
|
<div style="width: 100%;">
|
||||||
<slot name="header"></slot>
|
<slot name="header"></slot>
|
||||||
</div>
|
</div>
|
||||||
<div style="width: 100%;height: 100%;background-color: #f7f8fa;">
|
<div style="width: 100%;height: 100%;background-color: #f7f8fa;overflow-y: auto">
|
||||||
MAIN
|
MAIN
|
||||||
<slot>
|
<slot>
|
||||||
</slot>
|
</slot>
|
||||||
@ -18,23 +18,8 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import {ref} from 'vue';
|
import {ref} from 'vue';
|
||||||
|
|
||||||
const dataSources = ref({})
|
const dataSources = ref({})
|
||||||
|
|
||||||
const headerStyle = ref({});
|
|
||||||
|
|
||||||
|
|
||||||
const fitRect = function () {
|
|
||||||
const containerEl = document.getElementById('renderArea');
|
|
||||||
if (!containerEl) return;
|
|
||||||
const containerRect = containerEl.getBoundingClientRect();
|
|
||||||
headerStyle.value = {
|
|
||||||
overflowY: scroll,
|
|
||||||
width: `${containerRect.width}px`,
|
|
||||||
height: `${containerRect.height}px`,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
fitRect();
|
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@ -3,27 +3,38 @@
|
|||||||
style="width: fit-content; display: flex; flex-direction: column; position: relative;"
|
style="width: fit-content; display: flex; flex-direction: column; position: relative;"
|
||||||
v-if="store.nowComponentsData !== null && (componentVisible || store.designerMode)"
|
v-if="store.nowComponentsData !== null && (componentVisible || store.designerMode)"
|
||||||
:id="componentId"
|
:id="componentId"
|
||||||
:class="[
|
:class="['dynamic-component',{ 'hover-state': isHovered && store.designerMode },
|
||||||
'dynamic-component',
|
|
||||||
{ 'hover-state': isHovered && store.designerMode },
|
|
||||||
{ 'click-state': componentSelected && store.designerMode &&isComponent }
|
{ 'click-state': componentSelected && store.designerMode &&isComponent }
|
||||||
]"
|
]"
|
||||||
@click.stop="handleClick"
|
@click.stop="handleClick"
|
||||||
@mouseover="isHovered = true"
|
@mouseover="isHovered = true"
|
||||||
@mouseleave="isHovered = false"
|
@mouseleave="isHovered = false"
|
||||||
>
|
>
|
||||||
<div v-if="isHovered && store.designerMode" class="component-header">
|
<div v-if="isHovered && store.designerMode" id="header" class="component-header">
|
||||||
<span>{{ componentName }}</span>
|
<span>{{ componentName }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="componentSelected && store.designerMode&&isComponent" class="component-header" :style="headerStyle">
|
<div v-if="componentSelected && store.designerMode&&isComponent" class="component-header" :style="headerStyle">
|
||||||
<div style="background-color:#3457cc;color: #ffffff;padding: 5px ;margin-right: 2px">{{ componentName }}</div>
|
<div style="background-color:#3457cc;color: #ffffff;padding: 5px ;margin-right: 2px">{{ componentName }}</div>
|
||||||
<div style="background-color:#3457cc;color:#ffffff;padding: 6px 5px 5px 5px;display: flex;width: fit-content;flex-wrap: nowrap">
|
<div
|
||||||
<icon-copy class="clickable" size="20" />
|
style="background-color:#3457cc;color:#ffffff;padding: 6px 5px 5px 5px;display: flex;width: fit-content;flex-wrap: nowrap">
|
||||||
<icon-edit class="clickable" @click="handleEditFunc" size="20" />
|
<icon-copy class="clickable" size="20"/>
|
||||||
<icon-delete class="clickable" @click="handleDeleteFunc" size="20" />
|
<icon-edit class="clickable" @click="handleEditFunc" size="20"/>
|
||||||
|
<icon-delete class="clickable" @click="handleDeleteFunc" size="20"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="component-content">
|
<div class="component-content">
|
||||||
|
<VueDraggable
|
||||||
|
v-model="componentChildren"
|
||||||
|
:animation="150"
|
||||||
|
group="designer"
|
||||||
|
ghost-class="ghost"
|
||||||
|
chosen-class="chosen"
|
||||||
|
class="canvas"
|
||||||
|
@start="onComponentStart"
|
||||||
|
@update="onComponentUpdate"
|
||||||
|
@stop="onComponentEnd"
|
||||||
|
@add="onComponentAdd"
|
||||||
|
>
|
||||||
<component
|
<component
|
||||||
:is="componentType"
|
:is="componentType"
|
||||||
v-bind="componentPropsWithDisabled"
|
v-bind="componentPropsWithDisabled"
|
||||||
@ -32,46 +43,72 @@
|
|||||||
>
|
>
|
||||||
{{ componentText }}
|
{{ componentText }}
|
||||||
<template v-for="child in componentChildren" :key="child.id">
|
<template v-for="child in componentChildren" :key="child.id">
|
||||||
<DynamicComponent :componentData="child" />
|
<DynamicComponent :componentData="child"/>
|
||||||
</template>
|
</template>
|
||||||
<template v-for="(slot, key, index) in componentSlots" :key="index" v-slot:[key]>
|
<template v-for="(slot, key, index) in componentSlots" :key="key" v-slot:[key]>
|
||||||
<DynamicComponent :component-data="slot" />
|
<DynamicComponent :component-data="slot"/>
|
||||||
</template>
|
</template>
|
||||||
</component>
|
</component>
|
||||||
|
</VueDraggable>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { defineProps, ref, computed, onMounted, watch, markRaw, nextTick } from 'vue';
|
import {ref, computed, onMounted, watch, markRaw, nextTick} from 'vue';
|
||||||
import { componentMapping } from './componentMapping';
|
import {componentMapping} from './componentMapping';
|
||||||
import { useSchemeStore } from '../stores/useSchemeStore';
|
import {useSchemeStore} from '../stores/useSchemeStore';
|
||||||
|
import {DraggableEvent, VueDraggable} from "vue-draggable-plus";
|
||||||
|
|
||||||
const store = useSchemeStore();
|
const store = useSchemeStore();
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
componentData: Object
|
componentData: Object
|
||||||
});
|
});
|
||||||
const isComponent=ref(true)
|
const isComponent = ref(true)
|
||||||
const componentId = computed(() => props.componentData?.id || '');
|
const componentId = computed(() => props.componentData?.id || '');
|
||||||
const componentName = computed(() => props.componentData?.name || 'Unnamed Component');
|
const componentName = computed(() => props.componentData?.name || 'Unnamed Component');
|
||||||
const componentType = computed(() => markRaw(componentMapping[props.componentData?.type]) || 'div');
|
const componentType = computed(() => markRaw(componentMapping[props.componentData?.type]) || 'div');
|
||||||
const componentProps = computed(() => props.componentData?.props || {});
|
const componentProps = computed(() => props.componentData?.props || {});
|
||||||
const componentDisable = computed(() => props.componentData?.disable || false);
|
const componentDisable = computed(() => props.componentData?.disable);
|
||||||
const componentVisible = computed(() => props.componentData?.visible);
|
const componentVisible = computed(() => props.componentData?.visible);
|
||||||
const componentChildren = computed(() => props.componentData?.children || []);
|
const componentChildren = ref(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 || {});
|
const componentSlots = computed(() => props.componentData?.slots || {});
|
||||||
const componentSelected = computed(() => store.nowComponentsData?.id && props.componentData?.id === store.nowComponentsData?.id);
|
const componentSelected = computed(() => store.nowComponentsData?.id && props.componentData?.id === store.nowComponentsData?.id);
|
||||||
|
|
||||||
|
// 设计器控制参数
|
||||||
|
const componentMove = computed(() => props.componentData?.designer?.move | false);
|
||||||
|
const componentMoveSibling = computed(() => props.componentData?.designer?.moveSibling | false);
|
||||||
|
const componentSelect = computed(() => props.componentData?.designer?.select | false);
|
||||||
|
const componentDel = computed(() => props.componentData?.designer?.del | false);
|
||||||
|
const componentDynamic = computed(() => props.componentData?.designer?.dynamic | false);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
debugger
|
isComponent.value = props.componentData?.type != 'AdaptivePage';
|
||||||
isComponent.value=props.componentData?.type!='AdaptivePage';
|
|
||||||
adjustHeaderPosition();
|
adjustHeaderPosition();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const onComponentStart = (event: DraggableEvent) => {
|
||||||
|
console.log("onComponentStart", event);
|
||||||
|
}
|
||||||
|
|
||||||
|
const onComponentEnd = (event: DraggableEvent) => {
|
||||||
|
console.log("onComponentEnd", event);
|
||||||
|
|
||||||
|
}
|
||||||
|
const onComponentAdd = (event: DraggableEvent) => {
|
||||||
|
console.log("onComponentAdd", event);
|
||||||
|
let obj = getCurrentSchemeObj()
|
||||||
|
obj.children = componentChildren.value
|
||||||
|
store.updateScheme(obj.id, obj)
|
||||||
|
}
|
||||||
|
const onComponentUpdate = (event: DraggableEvent) => {
|
||||||
|
console.log("onComponentUpdate", event);
|
||||||
|
|
||||||
|
}
|
||||||
// 确保 componentProps 包含 disabled 属性
|
// 确保 componentProps 包含 disabled 属性
|
||||||
const componentPropsWithDisabled = computed(() => ({
|
const componentPropsWithDisabled = computed(() => ({
|
||||||
...componentProps.value,
|
...componentProps.value,
|
||||||
@ -88,6 +125,7 @@ const isHovered = ref(false);
|
|||||||
|
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
const currentComponent = getCurrentSchemeObj();
|
const currentComponent = getCurrentSchemeObj();
|
||||||
|
adjustHeaderPosition()
|
||||||
if (currentComponent) {
|
if (currentComponent) {
|
||||||
store.updateNowScheme(currentComponent);
|
store.updateNowScheme(currentComponent);
|
||||||
console.log(`Component with id ${currentComponent?.id} was clicked.`);
|
console.log(`Component with id ${currentComponent?.id} was clicked.`);
|
||||||
@ -108,18 +146,20 @@ const adjustHeaderPosition = () => {
|
|||||||
const componentEl = document.getElementById(componentId.value);
|
const componentEl = document.getElementById(componentId.value);
|
||||||
if (!componentEl) return;
|
if (!componentEl) return;
|
||||||
|
|
||||||
const headerEl = componentEl.querySelector('.component-header');
|
const headerEl = document.getElementById('header')
|
||||||
if (!headerEl) return;
|
if (!headerEl) return;
|
||||||
|
|
||||||
const componentRect = componentEl.getBoundingClientRect();
|
const componentRect = componentEl.getBoundingClientRect();
|
||||||
const headerRect = headerEl.getBoundingClientRect();
|
const headerRect = headerEl.getBoundingClientRect();
|
||||||
|
headerRect.height=headerRect.height+12
|
||||||
|
headerRect.width=headerRect.width+9
|
||||||
|
|
||||||
let top = 0;
|
let top = 0;
|
||||||
let left = 0;
|
let left = 0;
|
||||||
let justification = '';
|
let justification = '';
|
||||||
|
|
||||||
// 获取最外层组件渲染区域的边界
|
// 获取最外层组件渲染区域的边界
|
||||||
const containerEl = document.getElementById('renderArea');
|
const containerEl = document.getElementById('root');
|
||||||
if (!containerEl) return;
|
if (!containerEl) return;
|
||||||
|
|
||||||
const containerRect = containerEl.getBoundingClientRect();
|
const containerRect = containerEl.getBoundingClientRect();
|
||||||
@ -134,8 +174,8 @@ const adjustHeaderPosition = () => {
|
|||||||
} else if (bottomSpace >= headerRect.height) {
|
} else if (bottomSpace >= headerRect.height) {
|
||||||
top = componentRect.height - 2;
|
top = componentRect.height - 2;
|
||||||
}
|
}
|
||||||
|
debugger
|
||||||
if (headerRect.width > componentRect.width) {
|
if (headerRect.width > (componentRect.width+11)) {
|
||||||
left = -2;
|
left = -2;
|
||||||
justification = 'flex-start';
|
justification = 'flex-start';
|
||||||
} else {
|
} else {
|
||||||
@ -151,7 +191,6 @@ const adjustHeaderPosition = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
watch(() => componentSelected.value, () => {
|
watch(() => componentSelected.value, () => {
|
||||||
if (componentSelected.value) {
|
if (componentSelected.value) {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
@ -162,7 +201,7 @@ watch(() => componentSelected.value, () => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<style scoped>
|
<style>
|
||||||
.dynamic-component {
|
.dynamic-component {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
@ -213,4 +252,20 @@ watch(() => componentSelected.value, () => {
|
|||||||
.clickable {
|
.clickable {
|
||||||
cursor: pointer; /* 当鼠标悬停在此元素上时,鼠标指针变为手形 */
|
cursor: pointer; /* 当鼠标悬停在此元素上时,鼠标指针变为手形 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.canvas {
|
||||||
|
background-color: #fff;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ghost {
|
||||||
|
background-color: #f2f3f5 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chosen {
|
||||||
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
||||||
|
background-color: #f0f0f0;
|
||||||
|
z-index: 1001;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
@ -1,22 +1,24 @@
|
|||||||
{
|
[
|
||||||
"type": "AdaptivePage",
|
{
|
||||||
|
"id": "AdaptivePage-b32bb7a33910000",
|
||||||
"name": "AdaptivePage",
|
"name": "AdaptivePage",
|
||||||
"id": "AdaptivePage",
|
"type": "AdaptivePage",
|
||||||
"version": "2.0",
|
|
||||||
"props": {},
|
"props": {},
|
||||||
"class": "",
|
"class": "",
|
||||||
|
"children": [],
|
||||||
"style": "",
|
"style": "",
|
||||||
"variables": {},
|
"visible": true,
|
||||||
|
"slots": {},
|
||||||
|
"disable": false,
|
||||||
|
"events": {},
|
||||||
|
"loop": {},
|
||||||
|
"body": [],
|
||||||
|
"designer": {},
|
||||||
"dataSources": {},
|
"dataSources": {},
|
||||||
"functions": {},
|
"functions": {},
|
||||||
|
"variables": {},
|
||||||
"orchestrations": {},
|
"orchestrations": {},
|
||||||
"events": {},
|
|
||||||
"slots": {},
|
|
||||||
"header": [],
|
|
||||||
"footer": [],
|
"footer": [],
|
||||||
"body": [],
|
"meta": {}
|
||||||
"meta": {},
|
}
|
||||||
"visible": true,
|
]
|
||||||
"disable": false,
|
|
||||||
"designer": {}
|
|
||||||
}
|
|
||||||
@ -37,7 +37,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</VueDraggable>
|
</VueDraggable>
|
||||||
</div>
|
</div>
|
||||||
<div ref="targetContent" id="renderArea" class="center">
|
<div ref="targetContent" class="center" id="renderArea">
|
||||||
<VueDraggable
|
<VueDraggable
|
||||||
v-model="store.previewScheme"
|
v-model="store.previewScheme"
|
||||||
:sort="true"
|
:sort="true"
|
||||||
@ -50,7 +50,7 @@
|
|||||||
@stop="onPreviewStop"
|
@stop="onPreviewStop"
|
||||||
@add="onPreViewAdd"
|
@add="onPreViewAdd"
|
||||||
>
|
>
|
||||||
<DynamicComponent v-for="component in store.previewScheme" :key="component.id" :componentData="component">
|
<DynamicComponent id="root" style="height: 100%;width: 100%" v-for="component in store.previewScheme" :key="component.id" :componentData="component">
|
||||||
{{ component.id }}
|
{{ component.id }}
|
||||||
</DynamicComponent>
|
</DynamicComponent>
|
||||||
</VueDraggable>
|
</VueDraggable>
|
||||||
@ -63,7 +63,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { RadioGroup, Radio } from '@arco-design/web-vue';
|
|
||||||
import { onMounted, ref, watch } from 'vue';
|
import { onMounted, ref, watch } from 'vue';
|
||||||
import { uuid } from 'lsp-uuid';
|
import { uuid } from 'lsp-uuid';
|
||||||
import { componentScheme } from '@/schemes/scheme.ts';
|
import { componentScheme } from '@/schemes/scheme.ts';
|
||||||
@ -78,7 +77,7 @@ let componentsList = [];
|
|||||||
const store = useSchemeStore();
|
const store = useSchemeStore();
|
||||||
|
|
||||||
watch(store, (n) => {
|
watch(store, (n) => {
|
||||||
console.log("store发生了变化", n);
|
// console.log("store发生了变化", n);
|
||||||
});
|
});
|
||||||
|
|
||||||
const baseScheme = {
|
const baseScheme = {
|
||||||
@ -286,7 +285,6 @@ const view = () => {
|
|||||||
.ghost {
|
.ghost {
|
||||||
background-color: #f2f3f5 !important;
|
background-color: #f2f3f5 !important;
|
||||||
}
|
}
|
||||||
overflow-y: auto;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.right {
|
.right {
|
||||||
|
|||||||
Reference in New Issue
Block a user