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
d6f197bf
Commit
d6f197bf
authored
Apr 16, 2025
by
pangchong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 对比优化
parent
475e297c
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
104 additions
and
17 deletions
+104
-17
components.d.ts
+2
-0
src/components/GlobalModal.vue
+1
-1
src/configs/render-elem.ts
+1
-1
src/views/editor/components/Compare.vue
+35
-4
src/views/editor/constants/compare.ts
+2
-0
src/views/editor/functions/compare.ts
+57
-1
src/views/editor/functions/index.ts
+5
-9
src/views/editor/index.vue
+1
-1
No files found.
components.d.ts
View file @
d6f197bf
...
...
@@ -13,6 +13,7 @@ declare module 'vue' {
NCard
:
typeof
import
(
'naive-ui'
)[
'NCard'
]
NConfigProvider
:
typeof
import
(
'naive-ui'
)[
'NConfigProvider'
]
NDropdown
:
typeof
import
(
'naive-ui'
)[
'NDropdown'
]
NEmpty
:
typeof
import
(
'naive-ui'
)[
'NEmpty'
]
NInput
:
typeof
import
(
'naive-ui'
)[
'NInput'
]
NLayout
:
typeof
import
(
'naive-ui'
)[
'NLayout'
]
NLayoutContent
:
typeof
import
(
'naive-ui'
)[
'NLayoutContent'
]
...
...
@@ -21,6 +22,7 @@ declare module 'vue' {
NMessageProvider
:
typeof
import
(
'naive-ui'
)[
'NMessageProvider'
]
NModalProvider
:
typeof
import
(
'naive-ui'
)[
'NModalProvider'
]
NSpace
:
typeof
import
(
'naive-ui'
)[
'NSpace'
]
NSpin
:
typeof
import
(
'naive-ui'
)[
'NSpin'
]
NTree
:
typeof
import
(
'naive-ui'
)[
'NTree'
]
RouterLink
:
typeof
import
(
'vue-router'
)[
'RouterLink'
]
RouterView
:
typeof
import
(
'vue-router'
)[
'RouterView'
]
...
...
src/components/GlobalModal.vue
View file @
d6f197bf
<
template
>
<n-modal
v-bind=
"$attrs"
v-model:show=
"showModal"
:preset=
"preset"
:type=
"type"
>
<template
#
title
>
<template
#
header
>
<slot
name=
"title"
></slot>
</
template
>
<n-spin
class=
"w-full h-full"
content-class=
"w-full h-full"
:show=
"loading"
:description=
"description"
>
...
...
src/configs/render-elem.ts
View file @
d6f197bf
...
...
@@ -9,7 +9,7 @@ const renderElem = (type: string, style = { display: 'block' }) => {
const
modifyType
=
(
elem
as
any
).
modifyType
Object
.
assign
(
style
,
{
// @ts-ignore
paddingLef
t
:
Number
(
elem
.
dataIndent
)
*
10
+
'px'
textInden
t
:
Number
(
elem
.
dataIndent
)
*
10
+
'px'
})
return
h
(
type
,
...
...
src/views/editor/components/Compare.vue
View file @
d6f197bf
...
...
@@ -2,11 +2,23 @@
<GlobalModal
v-model=
"showCompare"
content-class=
"h-full overflow-hidden !p-0"
title=
"XML对比"
style=
"width: 99vw; height: 99vh"
preset=
"card"
:showFooter=
"false"
>
<template
#
title
>
<div
class=
"flex items-center justify-between"
>
<n-space>
XML对比
<n-button
@
click=
"uploadLeftXml"
>
上传左边文件
</n-button>
<n-button
@
click=
"clearLeftXml"
>
清除左边文件
</n-button>
</n-space>
<n-space>
<n-button
@
click=
"uploadRightXml"
>
上传右边文件
</n-button>
<n-button
@
click=
"clearRightXml"
>
清除右边文件
</n-button>
</n-space>
</div>
</
template
>
<div
class=
"flex h-full relative"
ref=
"compareContainerRef"
>
<div
class=
"choose-row bg-progressRailColor"
ref=
"chooseRowRef"
></div>
<GlobalEditor
...
...
@@ -28,8 +40,26 @@
</template>
<
script
setup
lang=
"ts"
>
import
{
showCompare
,
compareLeftRef
,
compareRightRef
,
compareContainerRef
,
chooseRowRef
,
compareData
}
from
'../constants/compare'
import
{
handleScrollTopLeft
,
handleScrollTopRight
}
from
'../functions/compare'
import
{
contentHoldNode
,
nodeSet
}
from
'@/configs/node.config'
import
{
showCompare
,
compareLeftRef
,
compareRightRef
,
compareContainerRef
,
chooseRowRef
,
compareData
,
compareLeftContent
,
compareRightContent
}
from
'../constants/compare'
import
{
clearLeftXml
,
clearRightXml
,
handleScrollTopLeft
,
handleScrollTopRight
,
uploadLeftXml
,
uploadRightXml
}
from
'../functions/compare'
watchEffect
(()
=>
{
if
(
compareLeftContent
.
value
&&
compareRightContent
.
value
)
{
const
xmlProcessing
=
useXMLProcessing
()
const
res
=
xmlProcessing
.
dualCompareFromString
(
compareLeftContent
.
value
,
compareRightContent
.
value
,
nodeSet
,
contentHoldNode
)
Object
.
assign
(
compareData
,
res
)
}
})
</
script
>
<
style
lang=
"less"
>
[
data-modify-type
=
'removed'
]
{
...
...
@@ -39,8 +69,9 @@ import { handleScrollTopLeft, handleScrollTopRight } from '../functions/compare'
background-color
:
var
(
--success-color-suppl
);
}
[
data-modify-type
=
'placeholder'
]
{
visibility
:
hidden
;
opacity
:
0.1
;
background-color
:
var
(
--warning-color-suppl
);
color
:
var
(
--warning-color-suppl
);
}
[
data-modify-type
=
'null-blank'
]
{
display
:
none
!important
;
...
...
src/views/editor/constants/compare.ts
View file @
d6f197bf
...
...
@@ -3,6 +3,8 @@ export const compareLeftRef = ref()
export
const
compareRightRef
=
ref
()
export
const
compareContainerRef
=
ref
()
export
const
chooseRowRef
=
ref
()
export
const
compareLeftContent
=
ref
()
export
const
compareRightContent
=
ref
()
export
const
compareData
=
reactive
<
{
treeOld
:
string
treeNew
:
string
...
...
src/views/editor/functions/compare.ts
View file @
d6f197bf
import
{
chooseRowRef
,
compareContainerRef
,
compareLeftRef
,
compareRightRef
,
showCompare
}
from
'../constants/compare'
import
{
contentHoldNode
,
nodeSet
}
from
'@/configs/node.config'
import
{
chooseRowRef
,
compareContainerRef
,
compareData
,
compareLeftContent
,
compareLeftRef
,
compareRightContent
,
compareRightRef
,
showCompare
}
from
'../constants/compare'
export
const
handleClickDom
=
(
event
:
any
)
=>
{
if
(
!
showCompare
.
value
)
return
...
...
@@ -20,3 +30,49 @@ export const handleScrollTopRight = (event: Event) => {
compareLeftRef
.
value
?.
handleScrollTop
(
scrollTop
)
chooseRowRef
.
value
.
style
.
height
=
'0px'
}
export
const
uploadLeftXml
=
async
()
=>
{
const
input
=
document
.
createElement
(
'input'
)
input
.
type
=
'file'
input
.
accept
=
'application/xml,text/xml'
input
.
multiple
=
false
input
.
click
()
input
.
addEventListener
(
'change'
,
async
(
event
:
Event
)
=>
{
const
files
=
(
event
.
target
as
HTMLInputElement
).
files
if
(
files
&&
files
.
length
>
0
)
{
const
file
=
files
[
0
]
const
xmlProcessing
=
useXMLProcessing
()
const
res
=
await
xmlProcessing
.
processFile
(
file
,
nodeSet
,
contentHoldNode
)
compareLeftContent
.
value
=
res
.
xmlContent
compareData
.
treeOld
=
res
.
xmlContent
}
input
.
remove
()
})
}
export
const
uploadRightXml
=
async
()
=>
{
const
input
=
document
.
createElement
(
'input'
)
input
.
type
=
'file'
input
.
accept
=
'application/xml,text/xml'
input
.
multiple
=
false
input
.
click
()
input
.
addEventListener
(
'change'
,
async
(
event
:
Event
)
=>
{
const
files
=
(
event
.
target
as
HTMLInputElement
).
files
if
(
files
&&
files
.
length
>
0
)
{
const
file
=
files
[
0
]
const
xmlProcessing
=
useXMLProcessing
()
const
res
=
await
xmlProcessing
.
processFile
(
file
,
nodeSet
,
contentHoldNode
)
compareRightContent
.
value
=
res
.
xmlContent
compareData
.
treeNew
=
res
.
xmlContent
}
input
.
remove
()
})
}
export
const
clearLeftXml
=
()
=>
{
compareData
.
treeNew
=
compareRightContent
.
value
compareLeftContent
.
value
=
''
compareData
.
treeOld
=
''
}
export
const
clearRightXml
=
()
=>
{
compareData
.
treeOld
=
compareLeftContent
.
value
compareRightContent
.
value
=
''
compareData
.
treeNew
=
''
}
src/views/editor/functions/index.ts
View file @
d6f197bf
...
...
@@ -3,11 +3,10 @@ import { IDomEditor } from '@wangeditor/editor'
import
{
treeData
,
treeRef
,
treeSelectedKeys
}
from
'../constants/tree'
import
{
dropdownConfig
,
editorRef
,
editorHtml
}
from
'../constants'
import
{
getUUID
}
from
'@/utils'
import
{
compareData
,
showCompare
}
from
'../constants/compare'
import
{
compareData
,
compareLeftContent
,
compareRightContent
,
showCompare
}
from
'../constants/compare'
import
TextA
from
'@/assets/file/CES-QEC-V250-A.xml?raw'
import
TextB
from
'@/assets/file/Trans-Convert.xml?raw'
import
{
nodeSet
,
contentHoldNode
}
from
'@/configs/node.config'
import
{
handleLeftDifferent
,
handleRightDifferent
}
from
'./compare'
export
const
handleCreated
=
(
editor
:
IDomEditor
)
=>
{
editorRef
.
value
=
editor
...
...
@@ -99,11 +98,8 @@ export const uploadXml = async () => {
//xml对比
export
const
compareXml
=
()
=>
{
showCompare
.
value
=
true
const
xmlProcessing
=
useXMLProcessing
()
const
res
=
xmlProcessing
.
dualCompareFromString
(
TextA
,
TextB
,
nodeSet
,
contentHoldNode
)
console
.
log
(
res
)
Object
.
assign
(
compareData
,
res
)
//比较数据
// handleLeftDifferent()
// handleRightDifferent()
compareData
.
treeOld
=
''
compareData
.
treeNew
=
''
compareLeftContent
.
value
=
''
compareRightContent
.
value
=
''
}
src/views/editor/index.vue
View file @
d6f197bf
...
...
@@ -6,7 +6,7 @@
<Toolbar
:editor=
"editorRef"
editorId=
"wangeEditor-1"
class=
"border-b border-solid border-borderColor"
/>
</div>
<n-space
class=
"bg-baseColor"
>
<n-button
@
click=
"uploadXml"
class=
"h-full"
type=
"error"
>
上传XML
</n-button>
<n-button
@
click=
"uploadXml"
class=
"h-full"
>
上传XML
</n-button>
<n-button
@
click=
"compareXml"
class=
"h-full"
>
XML对比
</n-button>
</n-space>
</div>
...
...
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