fix: DDS and drag will reset conponent props
This commit is contained in:
parent
9b2ee8ad46
commit
3fb59af2dd
|
@ -68,9 +68,7 @@
|
||||||
}" @mousedown.left.stop="startComponentDrag($event, component)" @mouseover="hoveredComponent = component.id"
|
}" @mousedown.left.stop="startComponentDrag($event, component)" @mouseover="hoveredComponent = component.id"
|
||||||
@mouseleave="hoveredComponent = null">
|
@mouseleave="hoveredComponent = null">
|
||||||
<!-- 动态渲染组件 -->
|
<!-- 动态渲染组件 -->
|
||||||
<KeepAlive>
|
<component :is="getComponentDefinition(component.type)" v-if="props.componentModules[component.type]"
|
||||||
<component :is="getComponentDefinition(component.type)" :key="component.id"
|
|
||||||
v-show="props.componentModules[component.type]"
|
|
||||||
v-bind="prepareComponentProps(component.attrs || {}, component.id)" @update:bindKey="
|
v-bind="prepareComponentProps(component.attrs || {}, component.id)" @update:bindKey="
|
||||||
(value: string) =>
|
(value: string) =>
|
||||||
updateComponentProp(component.id, 'bindKey', value)
|
updateComponentProp(component.id, 'bindKey', value)
|
||||||
|
@ -78,10 +76,9 @@
|
||||||
(pinInfo: any) =>
|
(pinInfo: any) =>
|
||||||
handlePinClick(component.id, pinInfo, pinInfo.originalEvent)
|
handlePinClick(component.id, pinInfo, pinInfo.originalEvent)
|
||||||
" :ref="(el: any) => setComponentRef(component.id, el)" />
|
" :ref="(el: any) => setComponentRef(component.id, el)" />
|
||||||
</KeepAlive>
|
|
||||||
|
|
||||||
<!-- Fallback if component module not loaded yet -->
|
<!-- Fallback if component module not loaded yet -->
|
||||||
<div v-if="!props.componentModules[component.type]"
|
<div v-else
|
||||||
class="p-2 text-xs text-gray-400 border border-dashed border-gray-400 flex items-center justify-center">
|
class="p-2 text-xs text-gray-400 border border-dashed border-gray-400 flex items-center justify-center">
|
||||||
<div class="flex flex-col items-center">
|
<div class="flex flex-col items-center">
|
||||||
<div class="loading loading-spinner loading-xs mb-1"></div>
|
<div class="loading loading-spinner loading-xs mb-1"></div>
|
||||||
|
@ -367,7 +364,7 @@ function prepareComponentProps(
|
||||||
if (componentId) {
|
if (componentId) {
|
||||||
result.componentId = componentId;
|
result.componentId = componentId;
|
||||||
}
|
}
|
||||||
console.log("Prepare Props", result);
|
// console.log(`组件属性 ID: ${componentId}`, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,6 +490,8 @@ function startComponentDrag(e: MouseEvent, component: DiagramPart) {
|
||||||
// 阻止事件冒泡
|
// 阻止事件冒泡
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
|
console.debug(`Start Drag Component: ${component.type}:${component.id}`)
|
||||||
|
|
||||||
// 设置拖拽状态
|
// 设置拖拽状态
|
||||||
draggingComponentId.value = component.id;
|
draggingComponentId.value = component.id;
|
||||||
isDragging.value = false;
|
isDragging.value = false;
|
||||||
|
@ -544,12 +543,12 @@ function onComponentDrag(e: MouseEvent) {
|
||||||
if (!draggedComponent) return;
|
if (!draggedComponent) return;
|
||||||
|
|
||||||
// 更新组件位置
|
// 更新组件位置
|
||||||
diagramData.value = updatePartPosition(
|
// diagramData.value = updatePartPosition(
|
||||||
diagramData.value,
|
// diagramData.value,
|
||||||
draggingComponentId.value,
|
// draggingComponentId.value,
|
||||||
Math.round(newX),
|
// Math.round(newX),
|
||||||
Math.round(newY),
|
// Math.round(newY),
|
||||||
);
|
// );
|
||||||
|
|
||||||
// 如果组件属于组,移动组内所有其他组件
|
// 如果组件属于组,移动组内所有其他组件
|
||||||
if (draggedComponent.group) {
|
if (draggedComponent.group) {
|
||||||
|
@ -565,14 +564,14 @@ function onComponentDrag(e: MouseEvent) {
|
||||||
);
|
);
|
||||||
|
|
||||||
// 更新这些组件的位置
|
// 更新这些组件的位置
|
||||||
for (const groupComp of groupComponents) {
|
// for (const groupComp of groupComponents) {
|
||||||
diagramData.value = updatePartPosition(
|
// diagramData.value = updatePartPosition(
|
||||||
diagramData.value,
|
// diagramData.value,
|
||||||
groupComp.id,
|
// groupComp.id,
|
||||||
groupComp.x + deltaX,
|
// groupComp.x + deltaX,
|
||||||
groupComp.y + deltaY,
|
// groupComp.y + deltaY,
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// 通知父组件位置已更新
|
// 通知父组件位置已更新
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, watch, onMounted } from 'vue';
|
import { ref, computed, watch, onMounted, watchEffect } from 'vue';
|
||||||
import Pin from './Pin.vue';
|
import Pin from './Pin.vue';
|
||||||
|
|
||||||
// 存储Pin引用
|
// 存储Pin引用
|
||||||
|
@ -94,6 +94,10 @@ const currentWaveformIndex = ref(0);
|
||||||
const waveformNames = ['正弦波', '方波', '三角波', '锯齿波'];
|
const waveformNames = ['正弦波', '方波', '三角波', '锯齿波'];
|
||||||
const waveforms = ['sine', 'square', 'triangle', 'sawtooth'];
|
const waveforms = ['sine', 'square', 'triangle', 'sawtooth'];
|
||||||
|
|
||||||
|
watchEffect(()=>{
|
||||||
|
console.log(`DDS Porperties: ${frequency.value} ${timebase.value}`)
|
||||||
|
})
|
||||||
|
|
||||||
// 波形函数集合
|
// 波形函数集合
|
||||||
interface WaveformFunction {
|
interface WaveformFunction {
|
||||||
(x: number, width: number, height: number, phaseRad: number): number;
|
(x: number, width: number, height: number, phaseRad: number): number;
|
||||||
|
|
|
@ -408,7 +408,7 @@ async function applyOutputWave() {
|
||||||
eqps.boardPort,
|
eqps.boardPort,
|
||||||
0,
|
0,
|
||||||
currentWaveformIndex.value,
|
currentWaveformIndex.value,
|
||||||
toInteger( frequency.value * Math.pow(2, 32 - 20) / 10 ),
|
toInteger(frequency.value * Math.pow(2, 32 - 20)),
|
||||||
);
|
);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
dialog.error("应用失败");
|
dialog.error("应用失败");
|
||||||
|
|
Loading…
Reference in New Issue