Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
Ifar-Xml-Edtor
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pangchong
Ifar-Xml-Edtor
Commits
bae2f4d0
Commit
bae2f4d0
authored
Jul 06, 2026
by
pangchong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 优化树菜单定位与高亮逻辑,当选中的是未生成虚拟节点的文本片段时自动回退到父级节点
parent
f13e58fd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
5 deletions
+23
-5
src/views/editor/components/NodeTree/functionals/index.ts
+18
-1
src/views/editor/components/NodeTree/index.vue
+5
-4
No files found.
src/views/editor/components/NodeTree/functionals/index.ts
View file @
bae2f4d0
...
...
@@ -445,6 +445,21 @@ export function useNodeTree(
return
text
.
replace
(
regex
,
'<mark class="highlight-mark">$1</mark>'
)
}
const
effectiveSelectedId
=
computed
(()
=>
{
const
selId
=
editorStore
.
selectedNodeId
if
(
!
selId
)
return
null
if
(
flatList
.
value
.
some
((
item
)
=>
item
.
id
===
selId
))
{
return
selId
}
if
(
selId
.
includes
(
'-txt-'
))
{
const
parentId
=
selId
.
split
(
'-txt-'
)[
0
]
if
(
flatList
.
value
.
some
((
item
)
=>
item
.
id
===
parentId
))
{
return
parentId
}
}
return
selId
})
// 树展开与定位同步辅助函数
const
syncTreeSelection
=
(
newId
:
string
|
null
,
shouldExpand
=
true
)
=>
{
if
(
!
newId
)
return
...
...
@@ -485,7 +500,8 @@ export function useNodeTree(
if
(
isTreeSelecting
.
value
)
{
return
}
const
idx
=
flatList
.
value
.
findIndex
((
item
)
=>
item
.
id
===
newId
)
const
targetScrollId
=
effectiveSelectedId
.
value
||
newId
const
idx
=
flatList
.
value
.
findIndex
((
item
)
=>
item
.
id
===
targetScrollId
)
if
(
idx
!==
-
1
&&
viewportRef
.
value
)
{
const
itemTop
=
idx
*
ITEM_HEIGHT
const
vHeight
=
viewportRef
.
value
.
clientHeight
...
...
@@ -1320,6 +1336,7 @@ export function useNodeTree(
handleScroll
,
hasCustomColor
,
getNodeStyle
,
effectiveSelectedId
,
// 批量管理模式
isBatchMode
,
selectedKeys
,
...
...
src/views/editor/components/NodeTree/index.vue
View file @
bae2f4d0
...
...
@@ -62,7 +62,7 @@
:key=
"item.id"
class=
"flex items-center h-[32px] px-2 rounded cursor-pointer transition-colors group/row tree-node-content"
:class=
"[
e
ditorStore.selectedNode
Id === item.id
e
ffectiveSelected
Id === item.id
? 'bg-primary text-white tree-node-selected'
: (showDropdown || isAnyModalVisible) && contextNodeId === item.id
? 'tree-node-context-active'
...
...
@@ -112,7 +112,7 @@
<div
v-if=
"item.hasChildren"
class=
"w-4 h-4 flex items-center justify-center mr-1 text-color3 hover:text-color1 cursor-pointer transition-colors z-10"
:class=
"[e
ditorStore.selectedNode
Id === item.id ? 'text-white/80 hover:text-white' : 'text-primary']"
:class=
"[e
ffectiveSelected
Id === item.id ? 'text-white/80 hover:text-white' : 'text-primary']"
@
click
.
stop=
"toggleExpand(item.id)"
>
<!-- 展开状态:减号 -->
...
...
@@ -131,7 +131,7 @@
<!-- Icon -->
<div
class=
"mr-1.5 flex items-center justify-center shrink-0 z-10"
:class=
"[e
ditorStore.selectedNode
Id === item.id ? 'text-white' : '']"
:class=
"[e
ffectiveSelected
Id === item.id ? 'text-white' : '']"
>
<n-icon
size=
"16"
>
<component
:is=
"getNodeIcon(item)"
/>
...
...
@@ -147,7 +147,7 @@
v-if=
"item.subtitle"
class=
"text-xs truncate"
:class=
"[
e
ditorStore.selectedNode
Id === item.id
e
ffectiveSelected
Id === item.id
? 'text-white/70'
: (showDropdown || isAnyModalVisible) && contextNodeId === item.id
? 'tree-node-context-active-subtitle'
...
...
@@ -249,6 +249,7 @@ const {
handleDropdownSelect
,
hasCustomColor
,
getNodeStyle
,
effectiveSelectedId
,
// 批量管理模式
isBatchMode
,
selectedKeys
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment