fix:工具栏绘制位置计算,组件宽度,高度自动占满
This commit is contained in:
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,5 +1,5 @@
|
|||||||
<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>
|
||||||
@ -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>
|
||||||
@ -10,7 +10,7 @@
|
|||||||
@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">
|
||||||
@ -83,8 +83,8 @@ const componentSelected = computed(() => store.nowComponentsData?.id && props.co
|
|||||||
const componentMove = computed(() => props.componentData?.designer?.move | false);
|
const componentMove = computed(() => props.componentData?.designer?.move | false);
|
||||||
const componentMoveSibling = computed(() => props.componentData?.designer?.moveSibling | false);
|
const componentMoveSibling = computed(() => props.componentData?.designer?.moveSibling | false);
|
||||||
const componentSelect = computed(() => props.componentData?.designer?.select | false);
|
const componentSelect = computed(() => props.componentData?.designer?.select | false);
|
||||||
const componentDel= computed(() => props.componentData?.designer?.del | false);
|
const componentDel = computed(() => props.componentData?.designer?.del | false);
|
||||||
const componentDynamic= computed(() => props.componentData?.designer?.dynamic | false);
|
const componentDynamic = computed(() => props.componentData?.designer?.dynamic | false);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
isComponent.value = props.componentData?.type != 'AdaptivePage';
|
isComponent.value = props.componentData?.type != 'AdaptivePage';
|
||||||
@ -125,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.`);
|
||||||
@ -145,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();
|
||||||
@ -171,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 {
|
||||||
@ -255,9 +258,11 @@ watch(() => componentSelected.value, () => {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ghost {
|
.ghost {
|
||||||
background-color: #f2f3f5 !important;
|
background-color: #f2f3f5 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chosen {
|
.chosen {
|
||||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
|
||||||
background-color: #f0f0f0;
|
background-color: #f0f0f0;
|
||||||
|
|||||||
@ -20,24 +20,5 @@
|
|||||||
"orchestrations": {},
|
"orchestrations": {},
|
||||||
"footer": [],
|
"footer": [],
|
||||||
"meta": {}
|
"meta": {}
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "AdaptivePage",
|
|
||||||
"name": "AdaptivePage",
|
|
||||||
"id": "718b3e933910000",
|
|
||||||
"version": "2.0",
|
|
||||||
"props": {},
|
|
||||||
"class": "",
|
|
||||||
"style": "",
|
|
||||||
"variables": {},
|
|
||||||
"dataSources": {},
|
|
||||||
"functions": {},
|
|
||||||
"orchestrations": {},
|
|
||||||
"events": {},
|
|
||||||
"slots": {},
|
|
||||||
"header": {},
|
|
||||||
"footer": {},
|
|
||||||
"children": [],
|
|
||||||
"meta": {}
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -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';
|
||||||
|
|||||||
Reference in New Issue
Block a user