V0.21.12.250611_alpha:修复数据监控搜索框的问题
This commit is contained in:
parent
2fe987f44a
commit
455f4ca783
Binary file not shown.
@ -161,7 +161,44 @@ class DataMonitor extends HTMLElement {
|
|||||||
// 设置新的定时器,300ms后执行搜索
|
// 设置新的定时器,300ms后执行搜索
|
||||||
this.searchTimeout = setTimeout(() => {
|
this.searchTimeout = setTimeout(() => {
|
||||||
this.filteredInterfaces = this.filterInterfaces(this.searchText);
|
this.filteredInterfaces = this.filterInterfaces(this.searchText);
|
||||||
this.render();
|
|
||||||
|
// 只更新树型控件部分
|
||||||
|
const treeView = this.shadowRoot.querySelector('.tree-view');
|
||||||
|
if (treeView) {
|
||||||
|
// 按ModelStructName分组
|
||||||
|
const groupedInterfaces = this.filteredInterfaces.reduce((groups, item) => {
|
||||||
|
const group = groups[item.ModelStructName] || [];
|
||||||
|
group.push(item);
|
||||||
|
groups[item.ModelStructName] = group;
|
||||||
|
return groups;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
// 更新树型控件内容
|
||||||
|
treeView.innerHTML = Object.entries(groupedInterfaces).map(([groupName, items]) => `
|
||||||
|
<div class="tree-group">
|
||||||
|
<div class="group-header" onclick="this.parentElement.querySelector('.group-content').classList.toggle('collapsed')">
|
||||||
|
<span class="group-icon">▼</span>
|
||||||
|
${groupName}
|
||||||
|
</div>
|
||||||
|
<div class="group-content">
|
||||||
|
${items.map(item => `
|
||||||
|
<div class="interface-item" data-interfacename="${item.InterfaceName}" data-modelstructname="${item.ModelStructName}">
|
||||||
|
${item.InterfaceName}
|
||||||
|
</div>
|
||||||
|
`).join('')}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`).join('');
|
||||||
|
|
||||||
|
// 重新绑定树节点双击事件
|
||||||
|
this.shadowRoot.querySelectorAll('.interface-item').forEach(itemEl => {
|
||||||
|
itemEl.ondblclick = (e) => {
|
||||||
|
const name = itemEl.getAttribute('data-interfacename');
|
||||||
|
const struct = itemEl.getAttribute('data-modelstructname');
|
||||||
|
this.handleTreeItemDblClick({ InterfaceName: name, ModelStructName: struct });
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 在下一个事件循环中恢复焦点和光标位置
|
// 在下一个事件循环中恢复焦点和光标位置
|
||||||
requestAnimationFrame(() => {
|
requestAnimationFrame(() => {
|
||||||
@ -764,6 +801,7 @@ class DataMonitor extends HTMLElement {
|
|||||||
padding-right: 16px;
|
padding-right: 16px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
min-width: 300px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-box {
|
.search-box {
|
||||||
@ -781,10 +819,13 @@ class DataMonitor extends HTMLElement {
|
|||||||
.tree-view {
|
.tree-view {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
min-height: 200px;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tree-group {
|
.tree-group {
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.group-header {
|
.group-header {
|
||||||
@ -796,11 +837,14 @@ class DataMonitor extends HTMLElement {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 8px;
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.group-content {
|
.group-content {
|
||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
display: block;
|
display: block;
|
||||||
|
width: calc(100% - 20px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.group-content.collapsed {
|
.group-content.collapsed {
|
||||||
@ -813,6 +857,8 @@ class DataMonitor extends HTMLElement {
|
|||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
margin: 2px 0;
|
margin: 2px 0;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
.interface-item:hover {
|
.interface-item:hover {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user