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
823fc252
Commit
823fc252
authored
Apr 01, 2025
by
qlintonger xeno
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 新增data-key赋值设定+1
parent
07b9bd4e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
4 deletions
+25
-4
src/assets/file/Trans-Convert.xml
+0
-0
src/lib/XMLProcessor/src/core/Processing.ts
+12
-3
src/lib/XMLProcessor/src/index.ts
+11
-0
src/lib/XMLProcessor/src/typing/index.d.ts
+2
-1
No files found.
src/assets/file/Trans-Convert.xml
0 → 100644
View file @
823fc252
This diff is collapsed.
Click to expand it.
src/lib/XMLProcessor/src/core/Processing.ts
View file @
823fc252
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
import
{
TreeRenderResult
}
from
'@/lib/XMLProcessor/src/typing'
;
import
{
TreeRenderResult
}
from
'@/lib/XMLProcessor/src/typing'
;
// 引入 UUID 类用于生成唯一标识符
// 引入 UUID 类用于生成唯一标识符
import
{
UUID
}
from
'uuidjs'
;
import
{
UUID
}
from
'uuidjs'
;
import
{
md5
}
from
'js-md5'
// 定义 Processing 类,用于处理 XML 数据
// 定义 Processing 类,用于处理 XML 数据
export
class
Processing
{
export
class
Processing
{
...
@@ -20,7 +21,13 @@ export class Processing {
...
@@ -20,7 +21,13 @@ export class Processing {
}
}
dualCompareFromString
(
xmlStringA
:
string
,
xmlStringB
:
string
,
bothHandledNode
:
string
[])
{
dualCompareFromString
(
xmlStringA
:
string
,
xmlStringB
:
string
,
bothHandledNode
:
string
[])
{
const
treeA
=
this
.
domParser
.
parseFromString
(
xmlStringA
,
'text/xml'
);
const
treeB
=
this
.
domParser
.
parseFromString
(
xmlStringB
,
'text/xml'
);
const
resultA
=
this
.
innerHandle
(
treeA
.
documentElement
,
bothHandledNode
);
const
resultB
=
this
.
innerHandle
(
treeB
.
documentElement
,
bothHandledNode
)
treeA
.
documentElement
.
querySelectorAll
(
':not([data-key])'
).
forEach
((
node
)
=>
node
.
remove
())
treeB
.
documentElement
.
querySelectorAll
(
':not([data-key])'
).
forEach
((
node
)
=>
node
.
remove
())
console
.
log
(
'both -res'
,
{
resultA
,
resultB
})
}
}
// 处理 XML 字符串的方法,返回树形数据和 XML DOM 对象
// 处理 XML 字符串的方法,返回树形数据和 XML DOM 对象
...
@@ -91,7 +98,8 @@ export class Processing {
...
@@ -91,7 +98,8 @@ export class Processing {
label
:
domNode
.
nodeName
,
label
:
domNode
.
nodeName
,
children
:
[],
children
:
[],
index
:
0
,
index
:
0
,
chained
:
[
0
]
chained
:
[
0
],
hash
:
md5
.
hex
(
domNode
.
textContent
!
||
''
)
};
};
// 为 DOM 节点设置 data-key 属性
// 为 DOM 节点设置 data-key 属性
domNode
.
setAttribute
(
'data-key'
,
targetKey
);
domNode
.
setAttribute
(
'data-key'
,
targetKey
);
...
@@ -131,7 +139,8 @@ export class Processing {
...
@@ -131,7 +139,8 @@ export class Processing {
key
:
targetKey
,
key
:
targetKey
,
label
:
node
.
nodeName
,
label
:
node
.
nodeName
,
index
:
realIndex
,
index
:
realIndex
,
chained
:
[...
startChained
,
realIndex
]
chained
:
[...
startChained
,
realIndex
],
hash
:
md5
.
hex
(
node
.
textContent
!
||
''
)
};
};
// 为 DOM 节点设置 data-key 属性
// 为 DOM 节点设置 data-key 属性
node
.
setAttribute
(
'data-key'
,
targetKey
);
node
.
setAttribute
(
'data-key'
,
targetKey
);
...
...
src/lib/XMLProcessor/src/index.ts
View file @
823fc252
import
{
Processing
}
from
'@/lib/XMLProcessor/src/core/Processing.ts'
import
{
Processing
}
from
'@/lib/XMLProcessor/src/core/Processing.ts'
import
{
Plugin
,
getCurrentInstance
}
from
'vue'
import
{
Plugin
,
getCurrentInstance
}
from
'vue'
import
TextA
from
"@/assets/file/CES-QEC-V250-A.xml?raw"
import
TextB
from
"@/assets/file/Trans-Convert.xml?raw"
import
{
nodeSet
}
from
'@/views/editor/constants/nodeParsed.ts'
const
p
=
new
Processing
()
const
p
=
new
Processing
()
// @ts-ignore
window
.
$p
=
function
()
{
p
.
dualCompareFromString
(
TextA
,
TextB
,
nodeSet
)
}
export
const
XMLProcessing
:
Plugin
=
function
(
app
)
{
export
const
XMLProcessing
:
Plugin
=
function
(
app
)
{
app
.
provide
(
'xmlProcessing'
,
p
);
app
.
provide
(
'xmlProcessing'
,
p
);
}
}
...
...
src/lib/XMLProcessor/src/typing/index.d.ts
View file @
823fc252
...
@@ -2,7 +2,7 @@ export type TreeRenderResult = {
...
@@ -2,7 +2,7 @@ export type TreeRenderResult = {
key
:
string
,
key
:
string
,
label
:
string
,
label
:
string
,
children
?:
TreeRenderResult
[],
children
?:
TreeRenderResult
[],
hash
?
:
string
,
hash
:
string
,
index
:
number
,
index
:
number
,
chained
:
number
[]
chained
:
number
[]
}
}
\ No newline at end of file
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