fix: Component awlays reset
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="motherboard-container" :style="{
|
||||
<div class="motherboard-container" v-bind="$attrs" :style="{
|
||||
width: width + 'px',
|
||||
height: height + 'px',
|
||||
position: 'relative',
|
||||
@@ -9,21 +9,31 @@
|
||||
<image href="../equipments/svg/motherboard.svg" width="100%" height="100%" preserveAspectRatio="xMidYMid meet" />
|
||||
</svg>
|
||||
</div>
|
||||
<Teleport to="#ComponentCapabilities" v-if="selectecComponentID === props.componentId">
|
||||
<MotherBoardCaps :jtagAddr="eqps.boardAddr" :jtagPort="eqps.boardPort.toString()" />
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="tsx">
|
||||
import MotherBoardCaps from "./MotherBoardCaps.vue";
|
||||
import { useEquipments } from "@/stores/equipments";
|
||||
import { ref, computed, defineComponent, watchEffect } from "vue";
|
||||
import { ref, computed, watchEffect, inject } from "vue";
|
||||
import { CanvasCurrentSelectedComponentID } from "../InjectKeys";
|
||||
|
||||
// 主板特有属性
|
||||
export interface MotherBoardProps {
|
||||
size?: number;
|
||||
boardAddr?: string;
|
||||
boardPort?: string;
|
||||
componentId?: string;
|
||||
}
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: "pinClick", pinId: string): void;
|
||||
}>();
|
||||
|
||||
const props = withDefaults(defineProps<MotherBoardProps>(), getDefaultProps());
|
||||
const selectecComponentID = inject(CanvasCurrentSelectedComponentID, ref(null));
|
||||
|
||||
// 计算实际宽高
|
||||
const width = computed(() => 800 * props.size);
|
||||
@@ -34,9 +44,6 @@ const eqps = useEquipments();
|
||||
const bitstreamFile = ref<File | null>();
|
||||
|
||||
watchEffect(() => {
|
||||
console.trace(
|
||||
`board监听改动: ${props.size} ${props.boardAddr}:${props.boardPort}`,
|
||||
);
|
||||
eqps.setAddr(props.boardAddr);
|
||||
eqps.setPort(props.boardPort);
|
||||
});
|
||||
@@ -49,20 +56,6 @@ defineExpose({
|
||||
}),
|
||||
// 主板没有引脚,但为了接口一致性,提供一个空的getPinPosition方法
|
||||
getPinPosition: () => null,
|
||||
getCapabilities: () => {
|
||||
// 返回组件定义而不是直接返回JSX
|
||||
return defineComponent({
|
||||
name: "MotherBoardCaps",
|
||||
setup() {
|
||||
return () => (
|
||||
<MotherBoardCaps
|
||||
jtagAddr={eqps.boardAddr}
|
||||
jtagPort={eqps.boardPort.toString()}
|
||||
/>
|
||||
);
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -73,6 +66,7 @@ export function getDefaultProps(): MotherBoardProps {
|
||||
size: 1,
|
||||
boardAddr: "127.0.0.1",
|
||||
boardPort: "1234",
|
||||
componentId: "DefaultMotherBoardID",
|
||||
};
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -183,4 +183,4 @@ export function generatePropsFromAttrs(attrs: Record<string, any>): PropertyConf
|
||||
export function getPropValue(component: DiagramPart, propName: string): any {
|
||||
if (!component) return undefined;
|
||||
return (component as any)[propName];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user