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
a3e85107
Commit
a3e85107
authored
Apr 07, 2025
by
qlintonger xeno
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 使用LCS对比+12
parent
cde83139
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
13 deletions
+23
-13
src/assets/file/Trans-Convert.xml
+1
-2
src/lib/XMLProcessor/src/core/Processing.ts
+18
-9
src/lib/XMLProcessor/src/core/dualCompare.ts
+4
-2
No files found.
src/assets/file/Trans-Convert.xml
View file @
a3e85107
...
@@ -9,8 +9,7 @@
...
@@ -9,8 +9,7 @@
<CEP>
<CEP>
<EFFECT
EFFRG=
"001999"
></EFFECT>
<EFFECT
EFFRG=
"001999"
></EFFECT>
<TITLEC>
发动机QEC拆卸(V2500-A5系列)
</TITLEC>
<TITLEC>
发动机QEC拆卸(V2500-A5系列)
</TITLEC>
<TITLE>
Remove the Engine's QEC(V2500-A5 series)XXXX
</TITLE>
<TITLE>
Remove the Engine's QEC(V2500-A5 series)xxx
</TITLE>
<TITLE>
Remove the Engine's QEC(V2500-A5 series)XXXX
</TITLE>
<TOPIC
CK-LEVEL=
"C"
>
<TOPIC
CK-LEVEL=
"C"
>
<TITLEC>
飞机/发动机基本信息
</TITLEC>
<TITLEC>
飞机/发动机基本信息
</TITLEC>
<TITLE>
AIRCRAFT/ENGINE INFORMATION
</TITLE>
<TITLE>
AIRCRAFT/ENGINE INFORMATION
</TITLE>
...
...
src/lib/XMLProcessor/src/core/Processing.ts
View file @
a3e85107
// 引入 TreeRenderResult 类型,该类型定义在 @/lib/XMLProcessor/src/typing 模块中
// 引入 TreeRenderResult 类型,该类型定义在 @/lib/XMLProcessor/src/typing 模块中
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
{
dualCompare
}
from
'@/lib/XMLProcessor/src/core/dualCompare.ts'
import
{
dualCompare
}
from
'@/lib/XMLProcessor/src/core/dualCompare.ts'
// 定义 Processing 类,用于处理 XML 数据
// 定义 Processing 类,用于处理 XML 数据
export
class
Processing
{
export
class
Processing
{
...
@@ -60,23 +60,32 @@ export class Processing {
...
@@ -60,23 +60,32 @@ export class Processing {
treeA
.
documentElement
.
querySelectorAll
(
':not([data-key])'
).
forEach
((
node
)
=>
node
.
remove
())
treeA
.
documentElement
.
querySelectorAll
(
':not([data-key])'
).
forEach
((
node
)
=>
node
.
remove
())
treeB
.
documentElement
.
querySelectorAll
(
':not([data-key])'
).
forEach
((
node
)
=>
node
.
remove
())
treeB
.
documentElement
.
querySelectorAll
(
':not([data-key])'
).
forEach
((
node
)
=>
node
.
remove
())
// 扁平化所有节点
// 扁平化所有节点
const
resultAFlatted
=
this
.
flattenTree
(
resultA
).
filter
((
item
)
=>
{
const
resultAFlatted
=
this
.
flattenTree
(
resultA
)
.
filter
((
item
)
=>
{
return
contentHoldNode
.
includes
(
item
.
label
)
return
contentHoldNode
.
includes
(
item
.
label
)
})
})
const
resultBFlatted
=
this
.
flattenTree
(
resultB
).
filter
((
item
)
=>
{
.
map
((
item
,
index
)
=>
({
...
item
,
index
}))
const
resultBFlatted
=
this
.
flattenTree
(
resultB
)
.
filter
((
item
)
=>
{
return
contentHoldNode
.
includes
(
item
.
label
)
return
contentHoldNode
.
includes
(
item
.
label
)
})
})
.
map
((
item
,
index
)
=>
({
...
item
,
index
}))
const
results
=
dualCompare
(
resultAFlatted
,
resultBFlatted
)
const
results
=
dualCompare
(
resultAFlatted
,
resultBFlatted
).
filter
((
a
)
=>
a
.
type
!==
'same'
)
.
filter
(
a
=>
a
.
type
!==
'same'
);
console
.
log
(
'results here'
,
results
)
console
.
log
(
'results here'
,
results
)
const
dataForOld
:
OldTreeModification
=
{
const
dataForOld
:
OldTreeModification
=
{
Deleted
:
results
.
filter
(
item
=>
item
.
type
===
'deleted'
).
map
(
a
=>
a
.
item
)
Deleted
:
results
.
filter
(
(
item
)
=>
item
.
type
===
'deleted'
).
map
((
a
)
=>
a
.
item
)
}
}
const
dataForNew
:
NewTreeModification
=
{
const
dataForNew
:
NewTreeModification
=
{
Added
:
results
.
filter
(
item
=>
item
.
type
===
'added'
).
map
(
a
=>
a
.
item
)
Added
:
results
.
filter
(
(
item
)
=>
item
.
type
===
'added'
).
map
((
a
)
=>
a
.
item
)
}
}
return
{
return
{
...
@@ -88,7 +97,7 @@ export class Processing {
...
@@ -88,7 +97,7 @@ export class Processing {
treeNew
:
resultB
,
treeNew
:
resultB
,
xmlContentOld
:
this
.
serializeXML
(
treeA
),
xmlContentOld
:
this
.
serializeXML
(
treeA
),
xmlContentNew
:
this
.
serializeXML
(
treeB
)
xmlContentNew
:
this
.
serializeXML
(
treeB
)
}
;
}
}
}
// 处理 XML 字符串的方法,返回树形数据和 XML DOM 对象
// 处理 XML 字符串的方法,返回树形数据和 XML DOM 对象
...
...
src/lib/XMLProcessor/src/core/dualCompare.ts
View file @
a3e85107
...
@@ -5,6 +5,8 @@ export function dualCompare(oldItems: TreeRenderResultFlatted[], newItems: TreeR
...
@@ -5,6 +5,8 @@ export function dualCompare(oldItems: TreeRenderResultFlatted[], newItems: TreeR
const
oldItemsCount
=
oldItems
.
length
const
oldItemsCount
=
oldItems
.
length
const
newItemsCount
=
newItems
.
length
const
newItemsCount
=
newItems
.
length
console
.
log
(
'old and new'
,
{
oldItems
,
newItems
})
const
dp
:
number
[][]
=
Array
.
from
({
length
:
oldItemsCount
+
1
},
()
=>
Array
(
newItemsCount
+
1
).
fill
(
0
))
const
dp
:
number
[][]
=
Array
.
from
({
length
:
oldItemsCount
+
1
},
()
=>
Array
(
newItemsCount
+
1
).
fill
(
0
))
for
(
let
i
=
1
;
i
<=
oldItemsCount
;
i
++
)
{
for
(
let
i
=
1
;
i
<=
oldItemsCount
;
i
++
)
{
...
@@ -19,10 +21,10 @@ export function dualCompare(oldItems: TreeRenderResultFlatted[], newItems: TreeR
...
@@ -19,10 +21,10 @@ export function dualCompare(oldItems: TreeRenderResultFlatted[], newItems: TreeR
let
i
=
oldItemsCount
,
let
i
=
oldItemsCount
,
j
=
newItemsCount
j
=
newItemsCount
const
result
:
Array
<
{
type
:
'same'
|
'deleted'
|
'added'
;
item
:
TreeRenderResultFlatted
}
>
=
[]
const
result
:
Array
<
{
type
:
'same'
|
'deleted'
|
'added'
|
'changedOld'
|
'changedNew'
;
item
:
TreeRenderResultFlatted
}
>
=
[]
while
(
i
>
0
&&
j
>
0
)
{
while
(
i
>
0
&&
j
>
0
)
{
if
(
oldItems
[
i
-
1
].
hash
===
newItems
[
j
-
1
].
hash
&&
oldItems
[
i
-
1
].
label
===
newItems
[
j
-
1
].
label
)
{
if
(
oldItems
[
i
-
1
].
hash
===
newItems
[
j
-
1
].
hash
&&
oldItems
[
i
-
1
].
label
===
newItems
[
j
-
1
].
label
)
{
result
.
unshift
({
type
:
'same'
,
item
:
cloneDeep
(
oldItems
[
i
-
1
])
})
//
result.unshift({ type: 'same', item: cloneDeep(oldItems[i - 1]) })
i
--
i
--
j
--
j
--
}
else
if
(
dp
[
i
-
1
][
j
]
>
dp
[
i
][
j
-
1
])
{
}
else
if
(
dp
[
i
-
1
][
j
]
>
dp
[
i
][
j
-
1
])
{
...
...
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