修复同类型例化下相同信号选择重复高亮的 bug

This commit is contained in:
锦恢 2025-01-05 13:51:55 +08:00
parent 091bacf006
commit ab5fe740fd
4 changed files with 39 additions and 26 deletions

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="treeview-info"> <div class="treeview-info">
<div class="treeview-info-blank" v-if="!globalLookup.currentSelectEntity"> <div class="treeview-info-blank" v-if="!globalLookup.currentSelectContext">
{{ t('info.no-entity-select.cannot-display-view') }} {{ t('info.no-entity-select.cannot-display-view') }}
</div> </div>

View File

@ -2,7 +2,7 @@
<div class="module"> <div class="module">
<div @click="clickModule()" <div @click="clickModule()"
class="netlist-treeview-item" class="netlist-treeview-item"
:class="{'active': sameModule(module) }" :class="{'active': sameModule() }"
> >
<span class="module-tag-status" @click.stop="expandManage.click"> <span class="module-tag-status" @click.stop="expandManage.click">
<div :class="expandManage.expandTagClass"></div> <div :class="expandManage.expandTagClass"></div>
@ -36,6 +36,7 @@
v-for="(cell, index) in cells" v-for="(cell, index) in cells"
:module="cell.view" :module="cell.view"
:cell="cell.data" :cell="cell.data"
:prefix-name="cell.prefixName"
:render-name="cell.renderName" :render-name="cell.renderName"
:key="index" :key="index"
></modules> ></modules>
@ -47,7 +48,7 @@
<script setup> <script setup>
/* eslint-disable */ /* eslint-disable */
import { globalLookup } from '@/hook/global'; import { globalLookup } from '@/hook/global';
import { ModuleView } from '@/hook/render/yosys'; import { dotConnect, ModuleView } from '@/hook/render/yosys';
import { defineComponent, reactive, computed } from 'vue'; import { defineComponent, reactive, computed } from 'vue';
import { infoView } from './info'; import { infoView } from './info';
@ -63,10 +64,14 @@ const props = defineProps({
}, },
renderName: { renderName: {
type: String type: String
},
prefixName: {
type: String
} }
}); });
const module = props.module; const module = props.module;
const id = props.cell ? props.cell.id: module.id;
const renderName = computed(() => { const renderName = computed(() => {
return props.renderName ? props.renderName : module.name return props.renderName ? props.renderName : module.name
@ -78,7 +83,16 @@ const cells = [];
// ports & modules // ports & modules
for (const portName of module.nameToPort.keys()) { for (const portName of module.nameToPort.keys()) {
const port = module.nameToPort.get(portName);
// prefixName treeview port id
// 使 port.id port.id port
const portId = props.prefixName ?
dotConnect(props.prefixName, port.name) :
port.id;
ports.push({ ports.push({
id: portId,
data: port,
name: portName name: portName
}); });
} }
@ -91,10 +105,15 @@ for (const cellName of module.nameToCell.keys()) {
// //
continue; continue;
} }
if (cell.isInstantiation) { if (cell.isInstantiation) {
const prefixName = props.prefixName ?
dotConnect(props.prefixName, cell.name) :
cell.id;
cells.push({ cells.push({
name: cellName, name: cellName,
data: cell, data: cell,
prefixName,
view: cell.belongModuleView, view: cell.belongModuleView,
renderName: `${cellName} (${cell.belongModuleView.name})` renderName: `${cellName} (${cell.belongModuleView.name})`
}); });
@ -103,34 +122,26 @@ for (const cellName of module.nameToCell.keys()) {
function sameModule(module) { function sameModule() {
if (!globalLookup.currentSelectEntity) { if (!globalLookup.currentSelectContext) {
return false; return false;
} }
const currentView = globalLookup.currentSelectEntity.moduleView; return globalLookup.currentSelectContext.id === id;
const cell = globalLookup.currentSelectEntity.cell;
if (cell && props.cell !== cell) {
return false;
}
const data = globalLookup.currentSelectEntity.data;
return data.name === module.name && currentView.name === module.name;
} }
function samePort(port) { function samePort(port) {
if (!globalLookup.currentSelectEntity) { if (!globalLookup.currentSelectContext) {
return false; return false;
} }
const data = globalLookup.currentSelectEntity.data; return globalLookup.currentSelectContext.id === port.id;
const currentView = globalLookup.currentSelectEntity.moduleView;
return data.name === port.name && module.name === currentView.name;
} }
function clickPort(port) { function clickPort(port) {
const portView = module.nameToPort.get(port.name); const portView = module.nameToPort.get(port.name);
infoView.displayPort(portView); infoView.displayPort(portView);
globalLookup.currentSelectEntity = { globalLookup.currentSelectContext = {
id: port.id,
data: port, data: port,
type: 'port', type: 'port',
moduleView: props.module moduleView: props.module
@ -139,8 +150,9 @@ function clickPort(port) {
function clickModule() { function clickModule() {
infoView.displayModule(module, props.cell); infoView.displayModule(module, props.cell);
globalLookup.currentSelectEntity = { globalLookup.currentSelectContext = {
id: id,
data: props.module, data: props.module,
type: 'module', type: 'module',
moduleView: props.module, moduleView: props.module,

View File

@ -68,15 +68,15 @@ export const globalLookup = reactive({
/** /**
* @description 当前选择的实体可以是 wire也可以是 cell * @description 当前选择的实体可以是 wire也可以是 cell
* @type {import('./jsdoc').ICurrentSelectEntity} * @type {import('./jsdoc').ICurrentSelectContext}
*/ */
currentSelectEntity: undefined, currentSelectContext: undefined,
/** /**
* @description 右侧 treeview 选择的需要展示数据的实体 * @description 右侧 treeview 选择的需要展示数据的实体
* @type {Record<string, string>} * @type {Record<string, string>}
*/ */
currentSelectEntityInfo: {} currentSelectContextInfo: {}
}); });
function loadSetting() { function loadSetting() {

View File

@ -274,8 +274,9 @@ import { Cell, ModuleView } from "./render/yosys";
*/ */
/** /**
* @typedef ICurrentSelectEntity * @typedef ICurrentSelectContext
* @property {any} data 数据本体用于匹配 id * @property {string} id
* @property {any} data
* @property {'module' | 'port'} type 类型 * @property {'module' | 'port'} type 类型
* @property {ModuleView} moduleView 所在模块的数据视图 * @property {ModuleView} moduleView 所在模块的数据视图
* @property {Cell} [cell] 例化模块在原模块中的视图 * @property {Cell} [cell] 例化模块在原模块中的视图