fix: 别名树重启后显示错误 — EnsurePathLoaded 硬编码 siblingIndex=0 导致同名兄弟节点映射到同一 key;SetDataStore 补刷别名;别名明细日志改为 DEBUG
This commit is contained in:
parent
69bf5d6e39
commit
86abf2bf8d
@ -81,7 +81,7 @@ namespace NavisworksTransport.Core.AliasTree
|
||||
/// <summary>
|
||||
/// 计算同名兄弟节点中的位置
|
||||
/// </summary>
|
||||
private static int ComputeSiblingIndex(ModelItem item)
|
||||
internal static int ComputeSiblingIndex(ModelItem item)
|
||||
{
|
||||
var parent = item.Parent;
|
||||
if (parent == null) return 0;
|
||||
|
||||
@ -100,6 +100,10 @@ namespace NavisworksTransport.UI.WPF.Views
|
||||
var aliasMap = _dataStore?.LoadAll();
|
||||
if (aliasMap != null && aliasMap.Count > 0)
|
||||
EnsureAliasedPathsVisible(aliasMap);
|
||||
|
||||
// EnsureAliasedPathsVisible 可能创建了新节点,需要再刷一次别名到这些节点上
|
||||
if (_built)
|
||||
RefreshAliasesFromStore();
|
||||
}
|
||||
|
||||
private void RefreshAliasesFromStore()
|
||||
@ -718,7 +722,7 @@ namespace NavisworksTransport.UI.WPF.Views
|
||||
LogManager.Info($"[别名树] EnsureAliasedPathsVisible: 共 {aliasMap.Count} 条别名");
|
||||
foreach (var kvp in aliasMap)
|
||||
{
|
||||
LogManager.Info($"[别名树] alias: key={kvp.Key} -> \"{kvp.Value}\"");
|
||||
LogManager.Debug($"[别名树] alias: key={kvp.Key} -> \"{kvp.Value}\"");
|
||||
}
|
||||
|
||||
int loaded = 0;
|
||||
@ -803,8 +807,9 @@ namespace NavisworksTransport.UI.WPF.Views
|
||||
|
||||
if (child == null)
|
||||
{
|
||||
int siblingIdx = NavisworksTransport.Core.AliasTree.AliasNodeIdentity.ComputeSiblingIndex(targetModelItem);
|
||||
child = BuildNode(targetModelItem, aliasMap, displayAlias,
|
||||
treeNode.Depth + 1, treeNode.NodeKey, 0);
|
||||
treeNode.Depth + 1, treeNode.NodeKey, siblingIdx);
|
||||
if (child != null)
|
||||
{
|
||||
child.Parent = treeNode;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user