修复同类型例化下相同信号选择重复高亮的 bug
This commit is contained in:
parent
091bacf006
commit
ab5fe740fd
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<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') }}
|
||||
</div>
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
<div class="module">
|
||||
<div @click="clickModule()"
|
||||
class="netlist-treeview-item"
|
||||
:class="{'active': sameModule(module) }"
|
||||
:class="{'active': sameModule() }"
|
||||
>
|
||||
<span class="module-tag-status" @click.stop="expandManage.click">
|
||||
<div :class="expandManage.expandTagClass"></div>
|
||||
@ -36,6 +36,7 @@
|
||||
v-for="(cell, index) in cells"
|
||||
:module="cell.view"
|
||||
:cell="cell.data"
|
||||
:prefix-name="cell.prefixName"
|
||||
:render-name="cell.renderName"
|
||||
:key="index"
|
||||
></modules>
|
||||
@ -47,7 +48,7 @@
|
||||
<script setup>
|
||||
/* eslint-disable */
|
||||
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 { infoView } from './info';
|
||||
|
||||
@ -63,10 +64,14 @@ const props = defineProps({
|
||||
},
|
||||
renderName: {
|
||||
type: String
|
||||
},
|
||||
prefixName: {
|
||||
type: String
|
||||
}
|
||||
});
|
||||
|
||||
const module = props.module;
|
||||
const id = props.cell ? props.cell.id: module.id;
|
||||
|
||||
const renderName = computed(() => {
|
||||
return props.renderName ? props.renderName : module.name
|
||||
@ -78,7 +83,16 @@ const cells = [];
|
||||
|
||||
// 初始化渲染的子视图 ports & modules
|
||||
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({
|
||||
id: portId,
|
||||
data: port,
|
||||
name: portName
|
||||
});
|
||||
}
|
||||
@ -91,10 +105,15 @@ for (const cellName of module.nameToCell.keys()) {
|
||||
// 防止递归
|
||||
continue;
|
||||
}
|
||||
if (cell.isInstantiation) {
|
||||
if (cell.isInstantiation) {
|
||||
const prefixName = props.prefixName ?
|
||||
dotConnect(props.prefixName, cell.name) :
|
||||
cell.id;
|
||||
|
||||
cells.push({
|
||||
name: cellName,
|
||||
data: cell,
|
||||
prefixName,
|
||||
view: cell.belongModuleView,
|
||||
renderName: `${cellName} (${cell.belongModuleView.name})`
|
||||
});
|
||||
@ -103,34 +122,26 @@ for (const cellName of module.nameToCell.keys()) {
|
||||
|
||||
|
||||
|
||||
function sameModule(module) {
|
||||
if (!globalLookup.currentSelectEntity) {
|
||||
function sameModule() {
|
||||
if (!globalLookup.currentSelectContext) {
|
||||
return false;
|
||||
}
|
||||
const currentView = globalLookup.currentSelectEntity.moduleView;
|
||||
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;
|
||||
return globalLookup.currentSelectContext.id === id;
|
||||
}
|
||||
|
||||
function samePort(port) {
|
||||
if (!globalLookup.currentSelectEntity) {
|
||||
if (!globalLookup.currentSelectContext) {
|
||||
return false;
|
||||
}
|
||||
const data = globalLookup.currentSelectEntity.data;
|
||||
const currentView = globalLookup.currentSelectEntity.moduleView;
|
||||
return data.name === port.name && module.name === currentView.name;
|
||||
return globalLookup.currentSelectContext.id === port.id;
|
||||
}
|
||||
|
||||
function clickPort(port) {
|
||||
const portView = module.nameToPort.get(port.name);
|
||||
infoView.displayPort(portView);
|
||||
|
||||
globalLookup.currentSelectEntity = {
|
||||
globalLookup.currentSelectContext = {
|
||||
id: port.id,
|
||||
data: port,
|
||||
type: 'port',
|
||||
moduleView: props.module
|
||||
@ -139,8 +150,9 @@ function clickPort(port) {
|
||||
|
||||
function clickModule() {
|
||||
infoView.displayModule(module, props.cell);
|
||||
|
||||
globalLookup.currentSelectEntity = {
|
||||
|
||||
globalLookup.currentSelectContext = {
|
||||
id: id,
|
||||
data: props.module,
|
||||
type: 'module',
|
||||
moduleView: props.module,
|
||||
|
@ -68,15 +68,15 @@ export const globalLookup = reactive({
|
||||
|
||||
/**
|
||||
* @description 当前选择的实体,可以是 wire,也可以是 cell
|
||||
* @type {import('./jsdoc').ICurrentSelectEntity}
|
||||
* @type {import('./jsdoc').ICurrentSelectContext}
|
||||
*/
|
||||
currentSelectEntity: undefined,
|
||||
currentSelectContext: undefined,
|
||||
|
||||
/**
|
||||
* @description 右侧 treeview 选择的需要展示数据的实体
|
||||
* @type {Record<string, string>}
|
||||
*/
|
||||
currentSelectEntityInfo: {}
|
||||
currentSelectContextInfo: {}
|
||||
});
|
||||
|
||||
function loadSetting() {
|
||||
|
@ -274,8 +274,9 @@ import { Cell, ModuleView } from "./render/yosys";
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef ICurrentSelectEntity
|
||||
* @property {any} data 数据本体,用于匹配 id
|
||||
* @typedef ICurrentSelectContext
|
||||
* @property {string} id
|
||||
* @property {any} data
|
||||
* @property {'module' | 'port'} type 类型
|
||||
* @property {ModuleView} moduleView 所在模块的数据视图
|
||||
* @property {Cell} [cell] 例化模块在原模块中的视图
|
||||
|
Loading…
x
Reference in New Issue
Block a user