|
@@ -1,23 +1,21 @@
|
|
|
<template>
|
|
<template>
|
|
|
<div class="stage-wrapper" ref="stageWrapperRef" :style="getWrapperStyle">
|
|
<div class="stage-wrapper" ref="stageWrapperRef" :style="getWrapperStyle">
|
|
|
- <div class="stage" ref="stageRef" :style="getStyles.stageStyle">
|
|
|
|
|
|
|
+ <div class="stage" :style="getStyles.stageStyle">
|
|
|
<div ref="tipRef" class="tip-txt" :style="getStyles.tipStyle">{{ page?.name }}</div>
|
|
<div ref="tipRef" class="tip-txt" :style="getStyles.tipStyle">{{ page?.name }}</div>
|
|
|
|
|
+ <!-- 格子背景 -->
|
|
|
<div class="absolute transparent-bg" :style="getStyles.transpartBg"></div>
|
|
<div class="absolute transparent-bg" :style="getStyles.transpartBg"></div>
|
|
|
- <div
|
|
|
|
|
- ref="canvasRef"
|
|
|
|
|
- class="absolute"
|
|
|
|
|
- ondragover="return false"
|
|
|
|
|
- :style="getStyles.canvasStyle"
|
|
|
|
|
- @drop="handleDrop"
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ <!-- 画布区域 -->
|
|
|
|
|
+ <div ref="canvasRef" class="absolute" :style="getStyles.canvasStyle">
|
|
|
|
|
+ <!-- 网格背景 -->
|
|
|
<div class="canvas-grid" v-show="state.showBgGrid"></div>
|
|
<div class="canvas-grid" v-show="state.showBgGrid"></div>
|
|
|
- <!-- <ComponentWrapper
|
|
|
|
|
- v-for="item in projectStore.elements"
|
|
|
|
|
- v-show="item.visible"
|
|
|
|
|
- :component-data="item"
|
|
|
|
|
- :key="item.key"
|
|
|
|
|
- :style="{ zIndex: item.zIndex }"
|
|
|
|
|
- /> -->
|
|
|
|
|
|
|
+ <Nodes
|
|
|
|
|
+ :schema="page"
|
|
|
|
|
+ :style="{
|
|
|
|
|
+ ...getStyles.canvasStyle,
|
|
|
|
|
+ transform: '',
|
|
|
|
|
+ border: 'none'
|
|
|
|
|
+ }"
|
|
|
|
|
+ />
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
@@ -31,7 +29,8 @@ import type { Page } from '@/types/page'
|
|
|
import { ref, onMounted, onBeforeUnmount, computed, nextTick } from 'vue'
|
|
import { ref, onMounted, onBeforeUnmount, computed, nextTick } from 'vue'
|
|
|
import { useScroll, useElementSize, useResizeObserver } from '@vueuse/core'
|
|
import { useScroll, useElementSize, useResizeObserver } from '@vueuse/core'
|
|
|
import { useProjectStore } from '@/store/modules/project'
|
|
import { useProjectStore } from '@/store/modules/project'
|
|
|
-import ComponentWrapper from './ComponentWrapper.vue'
|
|
|
|
|
|
|
+
|
|
|
|
|
+import Nodes from './Nodes.vue'
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
const props = defineProps<{
|
|
|
state: StageState
|
|
state: StageState
|
|
@@ -41,7 +40,6 @@ const emit = defineEmits<{
|
|
|
changeState: [Partial<StageState>]
|
|
changeState: [Partial<StageState>]
|
|
|
}>()
|
|
}>()
|
|
|
const stageWrapperRef: Ref<HTMLElement | null> = ref(null)
|
|
const stageWrapperRef: Ref<HTMLElement | null> = ref(null)
|
|
|
-const stageRef: Ref<HTMLElement | null> = ref(null)
|
|
|
|
|
const canvasRef: Ref<HTMLElement | null> = ref(null)
|
|
const canvasRef: Ref<HTMLElement | null> = ref(null)
|
|
|
const { width: clientWidth, height: clientHeight } = useElementSize(stageWrapperRef)
|
|
const { width: clientWidth, height: clientHeight } = useElementSize(stageWrapperRef)
|
|
|
const projectStore = useProjectStore()
|
|
const projectStore = useProjectStore()
|
|
@@ -59,6 +57,7 @@ const getWrapperStyle = computed(() => {
|
|
|
const STAGE_SCALE = 3
|
|
const STAGE_SCALE = 3
|
|
|
const getStyles = computed(() => {
|
|
const getStyles = computed(() => {
|
|
|
const { width = 1280, height = 720, scale } = props.state
|
|
const { width = 1280, height = 720, scale } = props.state
|
|
|
|
|
+ const { page } = props
|
|
|
|
|
|
|
|
// 可滚动距离 至少2倍窗口大小
|
|
// 可滚动距离 至少2倍窗口大小
|
|
|
const scrollWidth =
|
|
const scrollWidth =
|
|
@@ -184,14 +183,6 @@ const initStagePosition = async () => {
|
|
|
|
|
|
|
|
stageWrapperRef.value!.scrollTo(centerX, centerY)
|
|
stageWrapperRef.value!.scrollTo(centerX, centerY)
|
|
|
}
|
|
}
|
|
|
-// 拖拽组件结束 添加组件到指定位置
|
|
|
|
|
-const handleDrop = (e: DragEvent) => {
|
|
|
|
|
- e.preventDefault()
|
|
|
|
|
- const { offsetX, offsetY } = e
|
|
|
|
|
- console.log('target positon:', offsetX, offsetY)
|
|
|
|
|
-
|
|
|
|
|
- // TODO 添加组件到画布
|
|
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
defineExpose({
|
|
defineExpose({
|
|
|
getPosition: () => canvasRef.value?.getBoundingClientRect(),
|
|
getPosition: () => canvasRef.value?.getBoundingClientRect(),
|
|
@@ -245,6 +236,7 @@ onBeforeUnmount(() => {
|
|
|
5px 0px;
|
|
5px 0px;
|
|
|
}
|
|
}
|
|
|
.canvas-grid {
|
|
.canvas-grid {
|
|
|
|
|
+ pointer-events: none;
|
|
|
position: absolute;
|
|
position: absolute;
|
|
|
left: 0;
|
|
left: 0;
|
|
|
top: 0;
|
|
top: 0;
|