fix: DDS and drag will reset conponent props

This commit is contained in:
SikongJueluo 2025-05-17 15:09:59 +08:00
parent 9b2ee8ad46
commit 3fb59af2dd
No known key found for this signature in database
3 changed files with 32 additions and 29 deletions

View File

@ -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,
// );
// }
}
//

View File

@ -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;

View File

@ -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("应用失败");