Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
胡锦波
/
org-manager-web
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
61cdf4e8
authored
Apr 07, 2022
by
胡锦波
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1. init 侧边栏功能初始化,交互优化
parent
997e878b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
2 deletions
src/views/pages/aside-panels/aside-panels.vue
src/views/pages/aside-panels/aside-panels.vue
View file @
61cdf4e8
...
@@ -3,6 +3,9 @@
...
@@ -3,6 +3,9 @@
<el-menu
<el-menu
class=
"aside-menu"
class=
"aside-menu"
@
select=
"changeMenu"
@
select=
"changeMenu"
@
open=
"onOpenSub"
@
close=
"onCloseSub"
:default-openeds=
"defaultOpeneds"
:default-active=
"defaultActive"
:default-active=
"defaultActive"
>
>
<components
<components
...
@@ -33,16 +36,28 @@
...
@@ -33,16 +36,28 @@
</template>
</template>
<
script
lang=
"ts"
>
<
script
lang=
"ts"
>
import
logger
from
"@/api/logger"
;
import
{
Direction
}
from
"@/router"
;
import
{
Direction
}
from
"@/router"
;
import
{
RouterEventer
}
from
"@/router/event-bus"
;
import
{
MetaHeader
}
from
"@/router/meta-header"
;
import
{
MetaHeader
}
from
"@/router/meta-header"
;
import
{
Component
,
Vue
}
from
"vue-property-decorator"
;
import
{
Component
,
Vue
}
from
"vue-property-decorator"
;
const
SEEEION_SUBMENUS_CACHE
=
"session-submenus-cache"
;
interface
Menus
{
key
:
Direction
|
MetaHeader
;
title
:
MetaHeader
;
icon
?:
string
;
direction
?:
Direction
;
content
?:
Menus
[];
matchUrl
?:
Direction
[];
}
@
Component
({
components
:
{}
})
@
Component
({
components
:
{}
})
export
default
class
Asidepanels
extends
Vue
{
export
default
class
Asidepanels
extends
Vue
{
private
defaultActive
=
MetaHeader
.
home
;
private
defaultActive
=
MetaHeader
.
home
;
private
defaultOpeneds
:
string
[]
=
[];
private
linkLine
=
"-"
;
private
linkLine
=
"-"
;
private
items
=
[
private
items
:
Menus
[]
=
[
{
{
key
:
Direction
.
Home
,
key
:
Direction
.
Home
,
title
:
MetaHeader
.
home
,
title
:
MetaHeader
.
home
,
...
@@ -107,11 +122,67 @@
...
@@ -107,11 +122,67 @@
},
},
];
];
created
()
{
RouterEventer
.
registerOnRouterChanged
(
this
,
()
=>
{
this
.
onRouterChange
();
}).
raiseOnRouterChanged
();
this
.
defaultOpeneds
=
this
.
getCacheSubMenus
();
}
private
onRouterChange
()
{
const
curDirection
=
this
.
getCurrentDirection
();
this
.
matchUrl
(
this
.
items
,
""
,
curDirection
);
}
private
onOpenSub
(
key
:
string
)
{
const
v
=
this
.
getCacheSubMenus
();
v
.
push
(
key
);
this
.
setCacheSubMenus
(
v
);
}
private
onCloseSub
(
key
:
string
)
{
let
v
=
this
.
getCacheSubMenus
();
v
=
v
.
filter
((
i
:
string
)
=>
i
!==
key
);
this
.
setCacheSubMenus
(
v
);
}
private
matchUrl
(
items
:
Menus
[],
parent
:
MetaHeader
,
direction
:
Direction
)
{
for
(
let
i
=
0
;
i
<
items
.
length
;
i
++
)
{
const
t
=
items
[
i
];
if
(
(
t
.
direction
&&
t
.
direction
===
direction
)
||
(
t
.
matchUrl
&&
t
.
matchUrl
.
includes
(
direction
))
)
{
this
.
defaultActive
=
`
${
parent
}${
t
.
direction
}
`
;
return
;
}
if
(
t
.
content
&&
t
.
content
.
length
)
{
this
.
matchUrl
(
t
.
content
,
`
${
parent
}${
t
.
key
}${
this
.
linkLine
}
`
,
direction
);
}
}
}
private
changeMenu
(
key
:
string
)
{
private
changeMenu
(
key
:
string
)
{
const
arr
=
key
.
split
(
this
.
linkLine
);
const
arr
=
key
.
split
(
this
.
linkLine
);
const
direction
=
+
arr
[
arr
.
length
-
1
]
as
Direction
;
const
direction
=
+
arr
[
arr
.
length
-
1
]
as
Direction
;
this
.
go
(
direction
);
this
.
go
(
direction
);
}
}
private
getCacheSubMenus
()
{
const
t
=
sessionStorage
.
getItem
(
SEEEION_SUBMENUS_CACHE
);
if
(
t
)
{
return
JSON
.
parse
(
t
)
as
string
[];
}
return
[];
}
private
setCacheSubMenus
(
v
:
string
[])
{
sessionStorage
.
setItem
(
SEEEION_SUBMENUS_CACHE
,
JSON
.
stringify
(
v
));
}
}
}
</
script
>
</
script
>
...
...
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