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