Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vue3_onlineEditor
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
vue3_onlineEditor
Commits
f8b097f2
Commit
f8b097f2
authored
Apr 03, 2025
by
qlintonger xeno
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 修复额外内容+12345
parent
4c834970
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
2 deletions
+42
-2
src/lib/XMLProcessor/src/core/Processing.ts
+42
-2
No files found.
src/lib/XMLProcessor/src/core/Processing.ts
View file @
f8b097f2
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
import
{
NewTreeModification
,
OldTreeModification
,
TreeRenderResult
,
TreeRenderResultFlatted
}
from
'@/lib/XMLProcessor/src/typing'
import
{
NewTreeModification
,
OldTreeModification
,
TreeRenderResult
,
TreeRenderResultFlatted
}
from
'@/lib/XMLProcessor/src/typing'
import
{
md5
}
from
'js-md5'
import
{
md5
}
from
'js-md5'
import
{
getUUID
}
from
'../utils/uuid.ts'
import
{
getUUID
}
from
'../utils/uuid.ts'
import
{
cloneDeep
}
from
'lodash'
// 定义 Processing 类,用于处理 XML 数据
// 定义 Processing 类,用于处理 XML 数据
export
class
Processing
{
export
class
Processing
{
...
@@ -106,10 +107,48 @@ export class Processing {
...
@@ -106,10 +107,48 @@ export class Processing {
return
!
nodeChangedInOld
.
find
(
v
=>
v
.
key
===
a
.
key
);
return
!
nodeChangedInOld
.
find
(
v
=>
v
.
key
===
a
.
key
);
});
});
cons
t
stillDiffInNew
=
nonSameInNew
.
filter
(
a
=>
{
le
t
stillDiffInNew
=
nonSameInNew
.
filter
(
a
=>
{
return
!
nodeChangedInNew
.
find
(
v
=>
v
.
key
===
a
.
key
);
return
!
nodeChangedInNew
.
find
(
v
=>
v
.
key
===
a
.
key
);
});
});
// 以PARA和TITLE构建一组树,只追踪到上一级父节点即可,仅对新增节点有效
// 首先筛选出基层节点PARA和TITLE即可
let
allBaseNodeInNew
=
stillDiffInNew
.
filter
(
a
=>
{
return
a
.
label
===
'PARA'
||
a
.
label
===
'TITLE'
;
});
// 构建树节点
let
newDom
=
allBaseNodeInNew
.
map
(
a
=>
{
let
chainedParentNode
:
TreeRenderResultFlatted
[]
=
[
a
];
let
currentA
=
treeB
.
documentElement
.
querySelector
(
`[data-key="
${
a
.
key
}
"]`
)
while
(
currentA
)
{
currentA
=
currentA
.
parentElement
if
(
!
currentA
||
currentA
.
tagName
===
'JOBCARD'
)
{
break
}
let
keyVal
=
currentA
.
getAttribute
(
'data-key'
);
let
foundParentInNew
=
stillDiffInNew
.
find
(
v
=>
v
.
key
===
keyVal
);
if
(
foundParentInNew
)
{
chainedParentNode
.
push
(
foundParentInNew
)
}
}
chainedParentNode
.
reverse
();
let
targetChildren
=
null
return
chainedParentNode
.
reduce
((
acc
,
cur
)
=>
{
if
(
!
acc
)
{
// @ts-ignore
cur
.
children
=
[]
acc
=
cur
}
else
{
targetChildren
.
push
(
cur
)
// @ts-ignore
cur
.
children
=
[]
}
// @ts-ignore
targetChildren
=
cur
.
children
return
acc
;
},
null
as
null
|
TreeRenderResult
);
});
// 将修改的节点添加到结果中
// 将修改的节点添加到结果中
dataForOld
.
Changed
.
push
(...
nodeChangedInOld
);
dataForOld
.
Changed
.
push
(...
nodeChangedInOld
);
dataForNew
.
Changed
.
push
(...
nodeChangedInNew
);
dataForNew
.
Changed
.
push
(...
nodeChangedInNew
);
...
@@ -118,7 +157,8 @@ export class Processing {
...
@@ -118,7 +157,8 @@ export class Processing {
dataForOld
.
Deleted
.
push
(...
stillDiffInOld
);
dataForOld
.
Deleted
.
push
(...
stillDiffInOld
);
// 将新增的节点添加到结果中
// 将新增的节点添加到结果中
dataForNew
.
Added
.
push
(...
stillDiffInNew
);
// @ts-ignore
dataForNew
.
Added
.
push
(...
newDom
);
return
{
return
{
dataForNew
,
dataForNew
,
...
...
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