Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
common-templete
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
汤强勇
common-templete
Commits
199152a0
Commit
199152a0
authored
Nov 14, 2018
by
tangqy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整
parent
c0eceec1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
47 deletions
+46
-47
index.vue
src/components/Sidebar/index.vue
+46
-47
index1.vue
src/components/Sidebar/index1.vue
+0
-0
No files found.
src/components/Sidebar/index.vue
View file @
199152a0
...
...
@@ -4,7 +4,7 @@
.sidebar('@mouseover'="showUnfoldBtn()",'@mouseout'="hiddenUnfoldBtn()")
.logo
img(':src'="logo")
.item('v-if'="menus.length",'v-for'="(item,itemIndex) in menus" ,':key'="item.id",'@click'='choseMenu(item,itemIndex)',':class'="{active:
currentMainMenu
Index === itemIndex}")
.item('v-if'="menus.length",'v-for'="(item,itemIndex) in menus" ,':key'="item.id",'@click'='choseMenu(item,itemIndex)',':class'="{active:
first
Index === itemIndex}")
sidebar-item&attributes({
':icon':'item.ico',
':link':'item.link',
...
...
@@ -20,7 +20,6 @@
.children-item
el-menu&attributes({
'ref':"menu",
'default-active':"2",
'class':"el-menu-vertical",
'background-color':"#374A5E",
'text-color':"#fff",
...
...
@@ -55,8 +54,11 @@ export default {
collapse
:
false
,
logo
,
// unfold: false, // 水平展开
unfoldBtn
:
false
,
// 展开按钮
currentMainMenuIndex
:
0
,
//mainIndex
unfoldBtn
:
false
,
// 展开按钮
firstIndex
:
0
,
secondIndex
:
0
,
thirdIndex
:
0
,
currentMenus
:
[]
}
},
filters
:
{
...
...
@@ -77,47 +79,25 @@ export default {
currentPath
:
'getCurrentPath'
,
project
:
'getProjectInfo'
,
sidebarUnfoldInfo
:
'getSidebarUnfoldInfo'
,
}),
currentMenusIndex
()
{
let
res
=
-
1
if
(
this
.
currentPath
&&
this
.
currentPath
.
length
)
{
res
=
this
.
currentPath
[
0
]
this
.
$nextTick
(()
=>
{
this
.
handleOpen
()
})
}
return
res
},
currentMenus
:
{
get
()
{
// const currentIndex = this.currentMenusIndex
const
currentIndex
=
this
.
currentMainMenuIndex
const
currentMenus
=
currentIndex
===
-
1
?
this
.
getCurrentMenus
(
0
)
:
this
.
getCurrentMenus
(
currentIndex
)
this
.
$nextTick
(()
=>
{
if
(
this
.
currentMenus
)
{
this
.
handleOpen
()
// console.log('---', this.currentMenus)
}
})
return
currentMenus
},
},
})
},
mounted
()
{},
methods
:
{
handleOpen
()
{
const
menus
=
this
.
$refs
.
menu
const
openIndex
=
this
.
currentPath
.
length
===
3
?
this
.
currentPath
[
1
]
:
0
console
.
log
(
'openIndex'
,
openIndex
)
menus
.
open
(
openIndex
)
},
// calcRouter(menus) {
// const currentRoute = location.href
// const indexPath = calcIndexPathByCurrentRouter(menus, currentRoute)
// this.selectIndexPath = indexPath
// console.log(this.selectIndexPath)
// },
const
currentIndexPath
=
[
this
.
firstIndex
,
this
.
secondIndex
,
this
.
thirdIndex
]
console
.
log
(
currentIndexPath
)
const
menus
=
this
.
$refs
.
menu
console
.
log
(
menus
)
this
.
$nextTick
(()
=>
{
if
(
currentIndexPath
.
join
(
'-'
)
===
this
.
currentPath
.
join
(
'-'
))
{
menus
.
open
(
this
.
secondIndex
)
console
.
log
(
'open'
)
}
else
{
menus
.
close
(
this
.
secondIndex
)
console
.
log
(
'close'
)
}
})
},
// 隐藏边侧栏,边侧栏最小化
handerNoSidebar
()
{
console
.
log
(
'handerNoSidebar'
)
...
...
@@ -127,7 +107,9 @@ export default {
* 选择边测菜单主菜单
*/
choseMenu
(
selectItem
,
selectItemIndex
)
{
this
.
currentMainMenuIndex
=
selectItemIndex
console
.
log
(
'--'
,
selectItem
,
selectItemIndex
)
this
.
firstIndex
=
selectItemIndex
console
.
log
(
'current'
,
this
.
firstIndex
)
if
(
!
this
.
sidebarUnfoldInfo
)
{
this
.
toggleUnfold
(
true
)
}
...
...
@@ -148,10 +130,10 @@ export default {
**/
selectItemMenu
(
item
)
{
console
.
log
(
item
)
const
currentMenusIndex
=
this
.
currentMenus
Index
if
(
currentMenus
Index
>
-
1
)
{
const
firstIndex
=
this
.
first
Index
if
(
first
Index
>
-
1
)
{
const
[
idx1
,
idx2
]
=
item
.
split
(
'-'
).
reverse
()
const
historyItemName
=
this
.
menus
[
currentMenus
Index
].
children
[
idx1
].
children
[
idx2
].
name
const
historyItemName
=
this
.
menus
[
first
Index
].
children
[
idx1
].
children
[
idx2
].
name
const
time
=
this
.
$moment
().
format
(
'YYYY-MM-DD hh:mm:ss'
)
const
storeId
=
this
.
project
.
store_id
const
menuHistoryJson
=
localStorage
.
getItem
(
'menuHistoryJson'
+
storeId
)
...
...
@@ -160,7 +142,7 @@ export default {
menuHistoryJson
.
push
({
name
:
historyItemName
,
time
,
index
:
`
${(
currentMenus
Index
,
idx1
,
idx2
)}
`
,
index
:
`
${(
first
Index
,
idx1
,
idx2
)}
`
,
})
localStorage
.
setItem
(
'menuHistoryJson'
+
storeId
,
JSON
.
stringify
(
menuHistoryJson
))
crossStorage
.
onConnect
().
then
(
function
()
{
...
...
@@ -191,7 +173,24 @@ export default {
return
this
.
menus
[
index
]
},
...
mapActions
([
'setSidebarUnfold'
]),
},
},
watch
:
{
firstIndex
(
val
)
{
this
.
currentMenus
=
this
.
getCurrentMenus
(
val
)
this
.
$nextTick
(()
=>
{
this
.
handleOpen
()
})
},
currentPath
(
val
)
{
if
(
val
.
length
)
{
const
[
first
,
second
,
third
]
=
[...
val
]
this
.
firstIndex
=
first
this
.
secondIndex
=
second
this
.
thirdIndex
=
third
}
console
.
log
(
'currentPath is %o'
,
val
)
}
}
}
</
script
>
<
style
lang=
"stylus"
scoped
>
...
...
src/components/Sidebar/index1.vue
View file @
199152a0
This diff is collapsed.
Click to expand it.
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