Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
vridge-docs
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
JIRA
JIRA
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Gyeongho Park
vridge-docs
Commits
cb8ea044
Commit
cb8ea044
authored
Feb 24, 2023
by
shj
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[REFACTOR] index tree 생성 함수 리팩토링 & 미사용 코드 정리
parent
cd6e2b8d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
126 deletions
+33
-126
default.vue
docs-front/layouts/default.vue
+33
-126
No files found.
docs-front/layouts/default.vue
View file @
cb8ea044
...
@@ -284,11 +284,6 @@ export default{
...
@@ -284,11 +284,6 @@ export default{
guideIndex
:[],
guideIndex
:[],
selectedIndex
:
null
,
selectedIndex
:
null
,
loadingPageList
:
false
,
loadingPageList
:
false
,
targetParentId
:
null
,
createGuideTitle
:
''
,
createGuideContentKey
:
''
,
listGroup
:
null
,
call
:
0
,
scrollPositionRate
:
0
,
scrollPositionRate
:
0
,
showSearch
:
false
,
showSearch
:
false
,
...
@@ -316,15 +311,6 @@ export default{
...
@@ -316,15 +311,6 @@ export default{
logoEvent
(){
logoEvent
(){
this
.
openIndex
()
this
.
openIndex
()
},
},
isActiveMenu
(
id
)
{
if
(
this
.
$route
.
path
!==
'/'
&&
id
===
this
.
$store
.
state
.
guideId
)
{
return
true
}
return
false
},
// 가이드 페이지 이동
// 가이드 페이지 이동
openGuide
(
guide
)
{
openGuide
(
guide
)
{
this
.
selectedIndex
=
guide
this
.
selectedIndex
=
guide
...
@@ -336,33 +322,8 @@ export default{
...
@@ -336,33 +322,8 @@ export default{
await
this
.
$axios
.
get
(
'/test/index'
)
await
this
.
$axios
.
get
(
'/test/index'
)
.
then
(
res
=>
{
.
then
(
res
=>
{
this
.
rawIndexList
=
JSON
.
parse
(
JSON
.
stringify
(
res
.
data
));
this
.
rawIndexList
=
res
.
data
;
let
unclassifiedList
=
JSON
.
parse
(
JSON
.
stringify
(
res
.
data
));
this
.
getIndexTree
(
JSON
.
parse
(
JSON
.
stringify
(
res
.
data
)));
this
.
guideIndex
=
[]
// 최상위 목차(depth==1) 추출(path에 슬래시 갯수가 1개)
unclassifiedList
.
forEach
(
e
=>
{
if
(
e
.
path
.
split
(
'/'
).
length
===
2
)
this
.
guideIndex
.
push
(
e
)
});
this
.
guideIndex
.
forEach
(
parentEl
=>
{
parentEl
.
children
=
[]
// depth==2 추출
unclassifiedList
.
forEach
(
rawEl
=>
{
if
(
rawEl
.
path
!==
parentEl
.
path
&&
rawEl
.
path
.
includes
(
parentEl
.
path
)){
parentEl
.
children
.
push
(
rawEl
)
}
})
// depth==3 이하 추출
if
(
parentEl
.
children
.
length
>
0
){
this
.
setChildren
(
parentEl
.
children
,
parentEl
.
path
.
split
(
'/'
).
length
)
}
})
this
.
guideIndex
=
this
.
removeEmpty
(
this
.
guideIndex
)
})
})
.
catch
(
err
=>
{
.
catch
(
err
=>
{
console
.
log
(
err
)
console
.
log
(
err
)
...
@@ -370,81 +331,41 @@ export default{
...
@@ -370,81 +331,41 @@ export default{
this
.
activeNav
()
this
.
activeNav
()
this
.
loadingPageList
=
false
this
.
loadingPageList
=
false
this
.
createEditModeList
()
// this.activeGuideTreeIndex(this.guideIndex)
},
},
getIndexTree
(
unclassifiedList
){
let
indexTree
=
[]
setChildren
(
group
,
parentDepth
){
// depth 1 리스트 생성
group
.
forEach
(
g
=>
{
unclassifiedList
.
forEach
(
el
=>
{
if
(
g
.
path
.
split
(
'/'
).
length
!==
parentDepth
+
1
)
return
;
if
(
el
.
depth
===
1
){
indexTree
.
push
(
el
)
g
.
children
=
[]
delete
unclassifiedList
[
unclassifiedList
.
indexOf
(
el
)]
group
.
forEach
(
e
=>
{
if
(
e
.
path
.
includes
(
g
.
path
)
&&
e
.
path
!==
g
.
path
){
g
.
children
.
push
(
e
)
delete
group
[
group
.
indexOf
(
e
)]
}
})
if
(
g
.
children
.
length
>
0
){
this
.
setChildren
(
g
.
children
,
g
.
path
.
split
(
'/'
).
length
)
}
}
})
})
},
removeEmpty
(
item
){
let
noEmptyItem
=
[]
item
.
forEach
(
e
=>
{
if
(
e
)
noEmptyItem
.
push
(
e
)
})
noEmptyItem
.
forEach
(
e
=>
{
// depth 2 이상인 인덱스들 트리구조 생성
if
(
e
.
children
.
length
>
0
){
this
.
setTreeChild
(
indexTree
,
unclassifiedList
)
e
.
children
=
this
.
removeEmpty
(
e
.
children
)
}
})
return
noEmptyItem
this
.
guideIndex
=
JSON
.
parse
(
JSON
.
stringify
(
indexTree
))
this
.
editModeList
=
JSON
.
parse
(
JSON
.
stringify
(
indexTree
))
this
.
editModeRemainList
=
unclassifiedList
.
filter
(
el
=>
el
)
// empty 값 삭제
},
},
setTreeChild
(
targetList
,
unclassifiedList
){
targetList
.
forEach
(
el
=>
{
el
.
children
=
[]
// 로드된 페이지 index를 찾아서 활성화함
unclassifiedList
.
forEach
(
ucsfEl
=>
{
activeGuideTreeIndex
(
items
)
{
if
(
ucsfEl
.
path
.
indexOf
(
el
.
path
)
>
-
1
&&
ucsfEl
.
depth
===
el
.
depth
+
1
){
let
isFound
=
false
el
.
children
.
push
(
ucsfEl
)
delete
unclassifiedList
[
unclassifiedList
.
indexOf
(
ucsfEl
)]
items
.
forEach
(
g
=>
{
if
(
g
.
id
===
this
.
$route
.
params
.
guide
){
g
.
active
=
true
isFound
=
true
}
}
})
})
if
(
isFound
)
return
true
if
(
el
.
children
.
length
>
0
){
else
{
this
.
setEditModeChildren
(
el
.
children
,
unclassifiedList
)
items
.
forEach
(
g
=>
{
if
(
this
.
activeGuideTreeIndex
(
g
.
children
)){
g
.
active
=
true
}
}
})
})
}
},
// 재귀 호출로 트리 구조의 자식들 메뉴를 활성화
activeGuideTreeIndexRecursive
(
guide
,
parent
,
grandParent
)
{
if
(
guide
.
id
===
this
.
$store
.
state
.
guideId
)
{
guide
.
active
=
true
parent
.
active
=
true
grandParent
.
active
=
true
return
}
if
(
guide
.
children
)
{
for
(
let
i
=
0
;
i
<
guide
.
children
.
length
;
i
++
)
{
this
.
activeGuideTreeIndexRecursive
(
guide
.
children
[
i
],
guide
,
parent
)
}
}
},
},
editOn
(){
editOn
(){
if
(
this
.
keyword
===
'열려라 문'
){
if
(
this
.
keyword
===
'열려라 문'
){
this
.
editDialogActive
=
true
this
.
editDialogActive
=
true
...
@@ -456,30 +377,19 @@ export default{
...
@@ -456,30 +377,19 @@ export default{
this
.
editModeList
=
[]
this
.
editModeList
=
[]
this
.
editModeRemainList
=
[]
this
.
editModeRemainList
=
[]
// depth 이상치 확인
unclassifiedList
.
forEach
(
index
=>
{
if
(
!
index
.
depth
||
index
.
depth
<
1
){
this
.
editModeRemainList
.
push
(
index
)
delete
unclassifiedList
[
unclassifiedList
.
indexOf
(
index
)]
}
})
unclassifiedList
=
unclassifiedList
.
filter
(
el
=>
el
)
// empty 값 삭제
// depth 1 리스트 생성
// depth 1 리스트 생성
unclassifiedList
.
forEach
(
index
=>
{
unclassifiedList
.
forEach
(
index
=>
{
if
(
index
.
depth
===
1
){
if
(
index
.
depth
===
1
){
this
.
editModeList
.
push
(
index
)
this
.
editModeList
.
push
(
index
)
delete
unclassifiedList
[
unclassifiedList
.
indexOf
(
index
)]
// empty 처리
delete
unclassifiedList
[
unclassifiedList
.
indexOf
(
index
)]
}
}
})
})
unclassifiedList
=
unclassifiedList
.
filter
(
el
=>
el
)
// empty 값 삭제
// depth 2 이상인 인덱스들 트리구조 생성
// depth 2 이상인 인덱스들 트리구조 생성
this
.
setEditModeChildren
(
this
.
editModeList
,
unclassifiedList
)
this
.
setEditModeChildren
(
this
.
editModeList
,
unclassifiedList
)
unclassifiedList
=
unclassifiedList
.
filter
(
el
=>
el
)
// empty 값 삭제
this
.
editModeRemainList
.
push
(...
unclassifiedList
)
unclassifiedList
=
unclassifiedList
.
filter
(
el
=>
el
)
// empty 값 삭제
this
.
editModeRemainList
=
unclassifiedList
},
},
setEditModeChildren
(
targetList
,
unclassifiedList
){
setEditModeChildren
(
targetList
,
unclassifiedList
){
targetList
.
forEach
(
el
=>
{
targetList
.
forEach
(
el
=>
{
...
@@ -659,9 +569,6 @@ export default{
...
@@ -659,9 +569,6 @@ export default{
'$store.state.guideNavigator'
()
{
'$store.state.guideNavigator'
()
{
this
.
navPositionList
=
this
.
$store
.
state
.
guideNavigator
.
map
((
nav
)
=>
nav
.
position
)
this
.
navPositionList
=
this
.
$store
.
state
.
guideNavigator
.
map
((
nav
)
=>
nav
.
position
)
},
},
'$store.state.guideTreeFlag'
()
{
this
.
activeGuideTreeIndex
()
},
showSearch
(
val
){
showSearch
(
val
){
if
(
val
){
if
(
val
){
this
.
$nextTick
(()
=>
{
this
.
$nextTick
(()
=>
{
...
...
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